Sending Key-press to another process

  • Thread starter Thread starter Jarod_24
  • Start date Start date
J

Jarod_24

I got a "Process A" that starts several other programs.
Sometimes i want to send KeyBoard commands to these programs when i start
them.

For Example:

1. Process A starts Outlook
Process now got a process-object that points to the Outlook program

2. Process A send the Keybord commands "Ctrl+Shift+M" to OutLook


How do i do Step 2?

Remember that Process A can start up any kind of program, so this isn't just
for Outlook. It can be any kind of program.
 
* "Jarod_24 said:
I got a "Process A" that starts several other programs.
Sometimes i want to send KeyBoard commands to these programs when i start
them.

For Example:

1. Process A starts Outlook
Process now got a process-object that points to the Outlook program

2. Process A send the Keybord commands "Ctrl+Shift+M" to OutLook


How do i do Step 2?

Remember that Process A can start up any kind of program, so this isn't just
for Outlook. It can be any kind of program.

Have a look at 'AppActivate' and the methods of the 'SendKeys' class.
 
Herfried K. Wagner said:
Have a look at 'AppActivate' and the methods of the 'SendKeys' class.

AppActivate simply dosen't work.

I tried it and except for one time, it returns "invalid ProcessID" (when it
isn't)

I found out that the SetForegroundWindow API function can be used, but i
haven't a clue to what to do.
Anyone got any links to places where i can get a short introduction to these
API's and a little knowledge about how to code this in a VB.Net project?
It's impossible to find anything about this on MSDN.

SetForegroundWindow :
http://msdn.microsoft.com/library/d.../windows/windowreference/windowfunctions/setf
oregroundwindow.asp
 
Back
Top