hackman_3vilGuy
asked on
C# SendKeys to Foreground App
Hi,
I'm creating a program in C# that will run in the background on my pc. The program is a custom server and I will send a message to it remotely telling it to fake press a certain key. I have already made all of the code to receive the messages remotely and am just stuck where I actually have the key to send. I tried using SendKeys but this only seems to work for the active window whereas I want to be able to send keys remotely to the foreground app whatever it is or even to no window - just as if the key had been pressed on the keyboard.
Any ideas?
I'm creating a program in C# that will run in the background on my pc. The program is a custom server and I will send a message to it remotely telling it to fake press a certain key. I have already made all of the code to receive the messages remotely and am just stuck where I actually have the key to send. I tried using SendKeys but this only seems to work for the active window whereas I want to be able to send keys remotely to the foreground app whatever it is or even to no window - just as if the key had been pressed on the keyboard.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm using SendInput API
It will give you clues on getting the window handle, etc and then sending the msg (sendkeys) to it.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=923086&SiteID=1