Answer the question
In order to leave comments, you need to log in
Why does Spy++ have chCharCode = 1, while the bot has chCharCode = 97 with the same keystroke?
I am writing a bot that would copy text from a third-party program and paste it into mine. Faced such a problem. When pressing the Ctrl+A key combination in a third party program, Spy++ shows the following:
If my bot does this, then Spy++ shows this:
The combination does not work. If you simply write the letter 'a' in a third-party application, then Spy++ correctly returns chCharCode=97. And if in a combination, then for some reason (1). I also noticed that 1 is the serial number of the English character. For if you do the combination Ctrl + c, then Spy ++ will show chCharCode = 3, if Ctrl + N, then 14.
My code:
LPARAM lParam1,lParam2;
int ScanCode1 = MapVirtualKeyW(VK_CONTROL, 0);
int ScanCode2 = MapVirtualKeyW(WPARAM('A'), 0);
lParam1 = ScanCode1 << 16;
lParam2 = ScanCode2 << 16;
lParam1 |= 1;
lParam2 |= 1;
PostMessageW(hwnd, WM_KEYDOWN, VK_CONTROL, lParam1);
Sleep(25);
PostMessageW(hwnd, WM_KEYDOWN, WPARAM('A'), lParam2);
Sleep(25);
lParam1 |= 1 << 30;
lParam2 |= 1 << 30;
lParam1 |= 1 << 31;
lParam2 |= 1 << 31;
PostMessageW(hwnd,WM_KEYUP,WPARAM('A'),lParam2);
Sleep(25);
PostMessageW(hwnd, WM_KEYUP, VK_CONTROL, lParam1);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question