Hello there, I tried using WM_KEYDOWN and WM_KEYUP with this following code segment:
Code:
SetForegroundWindow(hwnd);
SendMessage(hwnd,WM_KEYDOWN, 0x00000011, 0x001D0001); // CTRL keydown
SendMessage(hwnd,WM_KEYDOWN, 0x00000053, 0x001F0001); // S keydown
SendMessage(hwnd,WM_KEYUP, 0x00000053, 0xC01F0001); // S keyup
SendMessage(hwnd,WM_KEYUP, 0x00000011, 0xC01D0001); // CTRL keyup
Still nothing happend, but then I decided to run Spy++ and monitor some of the activity, and this is what I got.
* This is what I logged when I ran my VC++ programming with the SendMessage code segment from above
Code:
<00001> 00EF01DE S WM_KEYDOWN nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00002> 00EF01DE R WM_KEYDOWN
<00003> 00EF01DE S WM_KEYDOWN nVirtKey:'S' cRepeat:1 ScanCode:1F fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00004> 00EF01DE R WM_KEYDOWN
<00005> 00EF01DE S WM_KEYUP nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:1 fUp:1
<00006> 00EF01DE R WM_KEYUP
<00007> 00EF01DE S WM_KEYUP nVirtKey:'S' cRepeat:1 ScanCode:1F fExtended:0 fAltDown:0 fRepeat:1 fUp:1
<00008> 00EF01DE R WM_KEYUP
<00009> 00EF01DE S WM_CHAR chCharCode:'
<00010> 00EF01DE R WM_CHAR
*This is what I logged when I manually pushed CTRL+S in notepad
Code:
<00011> 00EF01DE P WM_KEYDOWN nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00012> 00EF01DE P WM_KEYDOWN nVirtKey:'S' cRepeat:1 ScanCode:1F fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00013> 004006E0 P WM_KEYUP nVirtKey:'S' cRepeat:1 ScanCode:1F fExtended:0 fAltDown:0 fRepeat:1 fUp:1
<00014> 004006E0 P WM_KEYUP nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:1 fUp:1
As you can see from my SendMessage code above I mimicked the manual push of CTRL+S to notepad, but apparently nothing happend. The message type that is picked up by Spy++ when I do a SendMessage is listed as "Sent" and "Recieved", but the message type of a manual key press is listed as "Posted", when I do a keybd_event to stimulate CTRL+S, the message type gets listed as "Posted" and works like a charm. Is there a way to change the message type of SendMessage to be converted to a "Posted"?
I appreciate all the help, thanks!