C# SendKeys - Need to use SendKeys or any other method to set 'focus' to another application.

I have C# App. that launches another program. I need to write code that will set focus to the other application and do a paste. I have the code to paste.
Can not figure out how to set focus to the other app. Even if the other app. the top most app. The Send Keys does not work. Can I do a SendKeys Mouse Click?
TIA
LVL 1
JElsterAsked:
Who is Participating?
 
_TAD_Connect With a Mentor Commented:


<Call DLL>

[DllImport("User32",EntryPoint="SetForegroundWindow")]
private static extern bool SetForegroundWindow(System.IntPtr hWnd);



<Execute Function   -   Button Click Event>

if(prc.Responding)
{
     SetForegroundWindow(prc.MainWindowHandle);
     SendKeys.SendWait("_TAD_");
     SetForegroundWindow(this.Handle);
}




The process "prc" is a notpad process that I opened.
0
 
venkateshwarrCommented:
Hi JElster,
you can send relevant numer of "tab" keys to go to that particular field...

Cheers!
venkat.
0
 
JElsterAuthor Commented:
Does not work...
0
 
_TAD_Commented:


You'll need to use WinAPI to find the proper window and set the focus manually.


0
 
JElsterAuthor Commented:
Any idea how ? Thanks....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.