Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] How to send keydown event to inactive window?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
aasi888
How do I cheat?
Reputation: 0

Joined: 29 Jul 2009
Posts: 6

PostPosted: Tue Nov 03, 2015 2:42 pm    Post subject: [C++] How to send keydown event to inactive window? Reply with quote

[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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites