-
Member
Sending inputs to an inactive window
I'm trying to figure out how to send input to an inactive window (Path of Exile).
So far I managed to send some input to an inactive notepad window:
Code:
#include <Windows.h>
int main()
{
HWND hWnd = FindWindowA("Notepad", NULL);
HWND childHWND = FindWindowExA(hWnd, NULL, "Edit", NULL);
if (!hWnd) {
MessageBoxA(NULL, "Notepad window not found!", "Error", MB_OK);
return 1;
}
PostMessage(childHWND, WM_CHAR, 'a', 0);
return 0;
}
However this obviously doesn't work for PoE as they have some kind of an input system. Also I'd need it to press that button at a specific mouse location. It can be right click too instead of a keypress, doesn't matter. Any ideas?
Right now the best thing I managed to do was changing the active window back and forth but it's not as fast as I would want it to be.
-
Elite User
Avid Ailurophile


Originally Posted by
5waycarry
I'm trying to figure out how to send input to an inactive window (Path of Exile).
So far I managed to send some input to an inactive notepad window:
Code:
#include <Windows.h>
int main()
{
HWND hWnd = FindWindowA("Notepad", NULL);
HWND childHWND = FindWindowExA(hWnd, NULL, "Edit", NULL);
if (!hWnd) {
MessageBoxA(NULL, "Notepad window not found!", "Error", MB_OK);
return 1;
}
PostMessage(childHWND, WM_CHAR, 'a', 0);
return 0;
}
However this obviously doesn't work for PoE as they have some kind of an input system. Also I'd need it to press that button at a specific mouse location. It can be right click too instead of a keypress, doesn't matter. Any ideas?
Right now the best thing I managed to do was changing the active window back and forth but it's not as fast as I would want it to be.
Iirc Microsoft themselves block mouse input on inactive/background windows. Even with PostMessage/PostUserObject

"May all your bacon burn"

-
Member
Thanks. Unlucky
-
Originally Posted by
Razzue
Iirc Microsoft themselves block mouse input on inactive/background windows. Even with PostMessage/PostUserObject
I had luck with SendMessage in W10 for this purpose, haven't tried it on 11.
-
Active Member
Originally Posted by
Hazzbazzy
I had luck with SendMessage in W10 for this purpose, haven't tried it on 11.
he mean mouse events. any mouse click events to inactive windows will be filtered by basic window wndproc. cos mouse should be captured by window, but you cant a capture not a foreground window
-
-
Post Thanks / Like - 1 Thanks
Hazzbazzy (1 members gave Thanks to Razzue for this useful post)
-
Originally Posted by
Razzue
I have never been able to send a mouseclick to a background window via SendMessage (Of which both that, and PostMessage wrap NtPostUserObject, so if the direct syscall doesn't work neither would either of the wrappers.. ) on windows 10, plus depending on the game, they'd then have to worry about scrubbing the LLMH injected flags
Apologies, I cannot read on occasion and didn't see the obvious point about "mouse input"; was referring to keyboard input.
-
-
PoE will accept the mouse click event you send it, but it ignores the mouse location you pass in. It calls GetCursorPos() to get the current cursor position and sends the click to that location.
If you want background input with PoE, you're going to need to hook the necessary methods (or maybe find/modify their input method to actually use the passed in position instead of calling GetCursorPos()).
-
Post Thanks / Like - 2 Thanks