Click to See Complete Forum and Search --> : SendKeys
Archon
Aug 16th, 2000, 03:50 PM
I am coding a program using alot of API functions. At the end of the program i want to send the keys "{enter}" but everytime i do that: sendkeys "{enter}" the program freezes. Does anybody know how i can use an API to send the "{enter}" key stroke, instead of using the Sendkeys Utilitie?
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long
Private Const WM_CHAR = &H102
Private Sub Command1_Click
Call SendMessageByString(thehwndoftheprogram, WM_CHAR, 0&, Chr$(13))
End Sub
havent tried that, but it should work.
Archon
Aug 16th, 2000, 05:04 PM
No, it did not work. Nothing happens. No error no nothing.
Try this:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CHAR = &H102
Private Sub Command1_Click()
Call SendMessage(Me.hwnd, WM_CHAR, vbKeyReturn, 0)
End Sub
Archon
Aug 16th, 2000, 06:28 PM
Thank you Megatron. Tha code worked well.
Thanx
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.