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 


Is it possible to send direct key input with CE sendMessage

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

Joined: 21 Feb 2016
Posts: 115

PostPosted: Thu Feb 02, 2017 9:46 pm    Post subject: Is it possible to send direct key input with CE sendMessage Reply with quote

And if so how would one write something like that in CELua, for example sending 'z' key to notepad.exe window

Code:
 -- just guessing, this won't work of course
notepadHandle = findWindow('Untitled - Notepad')
sendMessage(notepadHandle, WM_KEYDOWN, 0x5A, 0)
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Thu Feb 02, 2017 10:51 pm    Post subject: Reply with quote

Your code was not far off from what CE can do:
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



More or less just an example of how to do this with notepad. This won't work on all processes and games. And this is more or less specific to how Notepads window is created.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Thu Feb 02, 2017 11:00 pm    Post subject: Reply with quote

Ah very cool, thanks for the help atom0s. And yeah I don't really have any game specific intentions quite yet, just interested in seeing what CE can do with this function Smile
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Wed Feb 08, 2017 2:55 pm    Post subject: Reply with quote

Can we change window position with this?
_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Sun Feb 12, 2017 2:37 pm    Post subject: Reply with quote

You can find a full list of system-defined messages that are usable with the SendMessage API here:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms644927(v=vs.85).aspx#system_defined

You could try using WM_SIZE / WM_MOVE but I've never personally tried to move a window like this so I cannot say for sure if it will work.

_________________
- 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