View previous topic :: View next topic |
Author |
Message |
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Thu Feb 02, 2017 9:46 pm Post subject: Is it possible to send direct key input with CE sendMessage |
|
|
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 |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Thu Feb 02, 2017 10:51 pm Post subject: |
|
|
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 |
|
|
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Thu Feb 02, 2017 11:00 pm Post subject: |
|
|
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
|
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Wed Feb 08, 2017 2:55 pm Post subject: |
|
|
Can we change window position with this?
_________________
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Sun Feb 12, 2017 2:37 pm Post subject: |
|
|
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 |
|
|
|