aasi888 How do I cheat?
Reputation: 0
Joined: 29 Jul 2009 Posts: 6
|
Posted: Tue Nov 03, 2015 2:42 pm Post subject: [C++] How to send keydown event to inactive window? |
|
|
[C++] How to send keydown event to inactive window?
KEYDOWN and KEYUP events are required as some actions ingame can only be done via keydown and keyup, such as moving my character or using hotkeys with modifiers.
Tab key works fine. But I'm having trouble with other keys such as "Z". Been googling this for a while but haven't found a solution so far.
| Code: | #include <iostream>
#include <Windows.h>
#include <string>
LPCSTR Target_window_Name = "Penisgobblers of the world"; //<- Has to match window name
HWND hGameWindowHandle = FindWindow(NULL,Target_window_Name);
int main()
{
//send TAB DOWN - WORKS FINE
SendMessage(hGameWindowHandle,WM_KEYDOWN,0x09,0);
//send TAB DOWN
SendMessage(hGameWindowHandle,WM_KEYUP,0x09,0);
//send Z DOWN - NOT WORKING
SendMessage(hGameWindowHandle,WM_KEYDOWN,0x5A,0);
//send Z UP
SendMessage(hGameWindowHandle,WM_KEYUP,0x5A,0);
return(0);
} |
Ps the virtual key 0x5A should be the correct scan code for letter Z.
|
|