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 


Control send ... send hotkey to background

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Twistedfate
Expert Cheater
Reputation: 0

Joined: 11 Mar 2016
Posts: 199

PostPosted: Sat Nov 11, 2017 3:07 pm    Post subject: Control send ... send hotkey to background Reply with quote

I want to send f1 to game running in background is that possible?how ?
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 12

Joined: 09 Aug 2013
Posts: 348

PostPosted: Sun Nov 12, 2017 8:53 am    Post subject: Reply with quote

I wrote this last night but apparently the website thought it was a sqlinject attack lol DB has probably fixed it since I'm no longer banned but... here's a link to pastebin anyways (same one I sent DB to show I really wasn't trying anything lol)

https://pastebin.com/fjFfw6rV
Back to top
View user's profile Send private message
Twistedfate
Expert Cheater
Reputation: 0

Joined: 11 Mar 2016
Posts: 199

PostPosted: Sun Nov 12, 2017 11:11 am    Post subject: Reply with quote

thank you for reply but I dont want to download external software .

this coded by atoms
I want to use something like that but to send key press to the window can we use sendMessage(hWnd ..

sorry I am still beginner
Code:
local hWndNotepad = findWindow('Notepad');
local hWndChild = getWindow(hWndNotepad, 5); -- Get the child edit control..

sendMessage(hWndChild, 0x0100, 0x48, 0); -- Send WM_KEYDOWN
sendMessage(hWndChild, 0x0101, 0x48, 0); -- Send WM_KEYUP
sendMessage(hWndChild, 0x0102, 0x48, 0); -- Send WM_CHAR


Can I edit this code to send key presses to the game I need something that
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 12

Joined: 09 Aug 2013
Posts: 348

PostPosted: Sun Nov 12, 2017 2:12 pm    Post subject: This post has 1 review(s) Reply with quote

Hm, I hadn't expected sendMessage to work based on something I'd found when googling before but that does. Presumably because it uses the child window

Since I'm not sure how atom0s found the number 5 all I can tell you is to test random numbers with your game and see if you can get it to work. While CE does have a "dissect windows" tool accessed from the memory browser for notepad it only shows the main window not the children for notepad so not sure if that'll be any use here...
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 137

Joined: 25 Jan 2006
Posts: 7309
Location: 127.0.0.1

PostPosted: Sun Nov 12, 2017 5:54 pm    Post subject: Reply with quote

You can read up on how getWindow works here:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633515(v=vs.85).aspx

It is just a wrapper around the normal Win32 API 'GetWindow'. The second param 5 means 'GW_CHILD', which means:

Quote:
The retrieved handle identifies the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved handle is NULL. The function examines only child windows of the specified window. It does not examine descendant windows.


In the example you mentioned that I wrote, it was just a hard-coded method to show a basic jist of sending keys to a child control of another window. I wouldn't recommend relying on using '5' all the time in other situations as the Z-order of controls is not guaranteed to be the same on all machines or on all launches of a process.

Instead, you should iterate over the controls and look for the specific one you want via using the GW_HWNDFIRST / GW_HWNDLAST / GW_HWNDNEXT commands.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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