Pressing Keys Code

oblique

New member
Joined
Dec 7, 2006
Messages
3
Programming Experience
Beginner
I am quite new to VB.Net. I just finished a corse on it creating fairly simple windows apps. This is what i would like my finished program to do:

-run my program.
-run another program.
-press a button on my program that will create a loop that will continually press a key that effects what happens in the other program.

Im not asking you to write the entire code for me, i just need the bit that will press the keys and a the bit that will make it work when a different program has focus. I will create the loops etc.

thanks alot for the help!
Oliver.
 
i dont want to send text, i just want the other program to think im pressing a key, say f12 for something like that.

thanks.
 
SendKeys doesn't send text, it sends keystrokes. The text is only in some cases a result of the key presses.

VB.NET:
SendKeys.Send("{F14}")
 
oh ok thanks. but i have been told that for it to work in another program, i have to use API's.... is this right? if so, could you please point me in the direction of how to use them?

thanks.
 
You mean SendKeys didn't work when you tried? I couldn't imagine why.

Btw, the function to activate other window (SetForegroundWindow) is a win32 api function. Depending on your situation you may have to use other api's to find the other window.
 
Back
Top