SendKey, sending the 'Enter' key and Keypress

Gluttard

Active member
Joined
Jan 9, 2008
Messages
44
Programming Experience
Beginner
Hello, I'm still a beginner at Visual Basic, but I feel I have a pretty good understanding so far.
First of all, I know the code to sendkeys such as letters and numbers, but when I try and send the 'Enter' key that would simulate the user hitting the enter button, nothing happens. If i'm in a text editing form such as where I'm typing this, it doesn't enter a carriage return.

Also, I know that the keypress event enables users to press keys and have them recognized by the program, but if the program is not the active window, it cannot be recognized. What can I do to overcome this? I figure a timer that constantly checks the state of a key, but what code would I put in?
 
but when I try and send the 'Enter' key that would simulate the user hitting the enter button, nothing happens. If i'm in a text editing form such as where I'm typing this, it doesn't enter a carriage return.
Yes, it does.
VB.NET:
AppActivate("VB.Net") 'start of window title that I know has a active textbox now...
SendKeys.Send("a{ENTER}b")
Also, I know that the keypress event enables users to press keys and have them recognized by the program, but if the program is not the active window, it cannot be recognized. What can I do to overcome this? I figure a timer that constantly checks the state of a key, but what code would I put in?
The keyboard events of your application handles keyboard events of your applications GUI only.
To listen for keyboard events that has nothing to do with your applications GUI you have to use something called "keyboard hook".
 
Oh, I was trying to enter the enter key by using, Keys.enter.
I figured that out right before you posted, next time I'll take some more time to think before I post.

And thanks for the other tip.
 
Back
Top