|
-
Apr 5th, 2004, 02:22 PM
#1
Thread Starter
Hyperactive Member
Press enter with api?[Solved]
Hi.
Is there a way i can press the enter button on the keyboard with api?
I know i can do:
but this might not always work...
So do you know a way to press enter with api?
Thanks!
Last edited by mike2; Apr 6th, 2004 at 01:16 AM.
-
Apr 5th, 2004, 05:00 PM
#2
The keyb_event API... Here's an example :
VB Code:
Const VK_H = 72
Const VK_E = 69
Const VK_L = 76
Const VK_O = 79
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
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 Sub Form_KeyPress(KeyAscii As Integer)
'Print the key on the form
Me.Print Chr$(KeyAscii);
End Sub
Private Sub Form_Paint()
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
'Clear the form
Me.Cls
keybd_event VK_H, 0, 0, 0 ' press H
keybd_event VK_H, 0, KEYEVENTF_KEYUP, 0 ' release H
keybd_event VK_E, 0, 0, 0 ' press E
keybd_event VK_E, 0, KEYEVENTF_KEYUP, 0 ' release E
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_O, 0, 0, 0 ' press O
keybd_event VK_O, 0, KEYEVENTF_KEYUP, 0 ' release O
End Sub
Now all you need to do is find the constant for "Enter"
Has someone helped you? Then you can Rate their helpful post. 
-
Apr 5th, 2004, 05:02 PM
#3
Turns out this works :
VB Code:
keybd_event vbKeyReturn, 0, 0, 0
keybd_event vbKeyReturn, 0, KEYEVENTF_KEYUP, 0
Has someone helped you? Then you can Rate their helpful post. 
-
Apr 6th, 2004, 01:15 AM
#4
Thread Starter
Hyperactive Member
Hmm...
Thanks.
This will probably work because the example worked!
Thanks
-
Apr 6th, 2004, 04:50 AM
#5
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
|