|
-
Jun 10th, 2001, 08:13 AM
#1
Thread Starter
New Member
How to simulate a key press???
I would like to know if someone could please tell me how to simulate a keyboard key press by API.
Thank you in advance.
-
Jun 10th, 2001, 08:19 AM
#2
Member
You don't neccessarily need an API call - try:
SendKeys "t"
SendKeys "hello world"
SendKeys "{TAB}"
SendKeys "{ENTER}"
SendKeys follows the form:
Code:
SendKeys string [,wait As Boolean]
so if you want to wait for the last key to be pressed before simulating another one, try:
SendKeys "{DEL}", True
Hope this helps!
-
Jun 10th, 2001, 08:38 AM
#3
Thread Starter
New Member
thank you very much, but I need the API because i am going to "convert" a joystick button signal to a keyboard key so I will need to use the keyup and keydown. The only possible way to do so is by API
-
Jun 10th, 2001, 07:35 PM
#4
Use the keybd_event API function.
VB Code:
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As _
Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal _
dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Sub Command1_Click()
Text1.SetFocus
keybd_event vbKeyH, 0, 0, 0
keybd_event vbKeyH, 0, KEYEVENTF_KEYUP, 0
keybd_event vbKeyE, 0, 0, 0
keybd_event vbKeyE, 0, KEYEVENTF_KEYUP, 0
keybd_event vbKeyL, 0, 0, 0
keybd_event vbKeyL, 0, KEYEVENTF_KEYUP, 0
keybd_event vbKeyL, 0, 0, 0
keybd_event vbKeyL, 0, KEYEVENTF_KEYUP, 0
keybd_event vbKeyO, 0, 0, 0
keybd_event vbKeyO, 0, KEYEVENTF_KEYUP, 0
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|