|
-
May 14th, 2004, 08:30 AM
#1
Thread Starter
Addicted Member
Sendmessage Assistance
Im a little new to Sendmessage... what im trying to do is send Ctrl Insert to another window. I know how to get the handle and what not just having a hard time with the sendmessage api to execute this task. Here is the keyboard output from spy++ of me hitting ctrl+ins.
If someone could give me a nudge in the correct direction...
Thanks for the help.
<00001> 00960098 P WM_KEYDOWN nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00002> 00960098 P WM_KEYDOWN nVirtKey:VK_INSERT cRepeat:1 ScanCode:52 fExtended:1 fAltDown:0 fRepeat:0 fUp:0
<00003> 00960098 P WM_KEYUP nVirtKey:VK_INSERT cRepeat:1 ScanCode:52 fExtended:1 fAltDown:0 fRepeat:1 fUp:1
<00004> 00960098 P WM_KEYUP nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:1 fUp:1
-------------------------
My name says it all!
-
May 15th, 2004, 10:28 PM
#2
Hyperactive Member
Big note.. I think you need to use postmessage, not sendmessage. I can't understand why, but i wasn't getting any results w/ sendmessage and in spy++, all real keystroke messages are posts. Also, I was trying to do a ctlr+v, but it didn't work. I even put in the repeat message for ctrl, and all i saw was a v. Maybe you can't do keyboard commands this way? ANYWAYS, this is what I gathered:
Did you have this so far?
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
You can get those by using the API Viewer in vb Tools>Addins, if it's not shown.
Once you load win32api.txt/mdb, they are under constants.
I think I got the correct lParam/wParam from checking the properties of a line in spy++. (It's best to log to a file, then copy from there. I couldn't copy any lines). Also, in the Messages>Options>Output> check Raw Message Paramters. That shows the _params it seems 
Public Const CTRL_WPARAM_VAL = &H00000011
Public Const CTRL_KEYD_LPARAM_VAL = &H001D0001
Public Const CTRL_KEYU_LPARAM_VAL = &HC01D0001
Public Const INSERT_WPARAM_VAL = &H0000002D
Public Const INSERT_KEYD_LPARAM_VAL = &H01520001
Public Const INSERT_KEYU_LPARAM_VAL = &HC1520001
something along the lines of..
SendMessage(hWin, WM_KEYDOWN, CTRL_WPARAM_VAL , CTRL_KEYD_LPARAM_VAL )
SendMessage(hWin, WM_KEYDOWN, INSERT_WPARAM_VAL , INSERT_KEYD_LPARAM_VAL )
SendMessage(hWin, WM_KEYUP, INSERT_WPARAM_VAL , INSERT_KEYU_LPARAM_VAL )
SendMessage(hWin, WM_KEYUP, CTRL_WPARAM_VAL , CTRL_KEYU_LPARAM_VAL )
lemme know if it works for you.
-
May 17th, 2004, 06:42 AM
#3
Thread Starter
Addicted Member
Resolved
Thanks for the reply...
I did get it to work with the following:
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 Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
Call keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0)
PostMessage hWn, WM_KEYDOWN, VK_INSERT, 0
Call keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0)
The first line holds the ctrl down while the 2nd line sends the insert key and last the 3rd line releases the ctrl key.
Took me a while to dig it up here but finally got it.
If you want me to post more of the code just let me know.
Thanks again for posting code for me to look at.
-------------------------
My name says it all!
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
|