|
-
Jun 26th, 2001, 05:33 PM
#1
Thread Starter
Addicted Member
Sendmessage api question?
using the api
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
what do the wParam and lParam do? what kinda stuff is specified in there...
and also how would i use sendmessage to send keydown event....
heres what i got...
Private Const WM_KEYDOWN = &H100
SendMessage apphwnd, WM_KEYDOWN, 0, 0
but what and where do i put if i want to call lets say H, E, L, L, O keys?
-
Jun 26th, 2001, 06:03 PM
#2
wParam and lParam both contain message information.
For example, to send H E L L O, you would use:
VB Code:
SendMessage hWindow, WM_KEYDOWN, vbKeyH, 0
SendMessage hWindow, WM_KEYUP, vbKeyH, 0
SendMessage hWindow, WM_KEYDOWN, vbKeyE, 0
SendMessage hWindow, WM_KEYUP, vbKeyE, 0
SendMessage hWindow, WM_KEYDOWN, vbKeyL, 0
SendMessage hWindow, WM_KEYUP, vbKeyL, 0
SendMessage hWindow, WM_KEYDOWN, vbKeyL, 0
SendMessage hWindow, WM_KEYUP, vbKeyL, 0
SendMessage hWindow, WM_KEYDOWN, vbKeyO, 0
SendMessage hWindow, WM_KEYUP, vbKeyO, 0
-
Jun 26th, 2001, 06:14 PM
#3
Thread Starter
Addicted Member
-
Jun 26th, 2001, 06:24 PM
#4
Thread Starter
Addicted Member
it gives me error 49
bad dll calling convention
on line
SendMessage hWindow, WM_KEYDOWN, vbKeyH, 0
-
Jun 26th, 2001, 06:51 PM
#5
Make sure you declare statement looks like this:
VB 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
-
Jun 26th, 2001, 07:04 PM
#6
Thread Starter
Addicted Member
hmm, lol
it gave me 5 e's
i dont think anything is wrong with the code, i think it is just the app tring to recive it....
its a game(half-life) in theconsole, i can type HELLO but if i do the code, i get eeeee
any ideas on how to fix this?
-
Jun 27th, 2001, 09:14 AM
#7
It's possible that the app your trying to send it to needs to recieve a WM_CHAR message as well. Try this:
VB Code:
SendMessage hWindow, WM_KEYDOWN, vbKeyH, 0
SendMessage hWindow, WM_CHAR, vbKeyH, 0
SendMessage hWindow, WM_KEYUP, vbKeyH, 0
SendMessage hWindow, WM_KEYDOWN, vbKeyE, 0
SendMessage hWindow, WM_CHAR, vbKeyE, 0
SendMessage hWindow, WM_KEYUP, vbKeyE, 0
SendMessage hWindow, WM_KEYDOWN, vbKeyL, 0
SendMessage hWindow, WM_CHAR, vbKeyL, 0
SendMessage hWindow, WM_KEYUP, vbKeyL, 0
SendMessage hWindow, WM_KEYDOWN, vbKeyL, 0
SendMessage hWindow, WM_CHAR, vbKeyL, 0
SendMessage hWindow, WM_KEYUP, vbKeyL, 0
SendMessage hWindow, WM_KEYDOWN, vbKeyO, 0
SendMessage hWindow, WM_CHAR, vbKeyO, 0
SendMessage hWindow, WM_KEYUP, vbKeyO, 0
-
Jun 27th, 2001, 09:17 AM
#8
You could also try a different (and shorter) approach by sending the WM_SETTEXT message.
VB Code:
sText = "Hello"
SendMessage hWindow, WM_SETTEXT, 0, ByVal sText
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
|