-
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?
-
Code:
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.
-
No, it did not work. Nothing happens. No error no nothing.
-
Try this:
Code:
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
-
Thank you Megatron. Tha code worked well.
Thanx