I know that using win32gui.PostMessage(hwnd, win32con.WM_MOUSEMOVE, wParam, lParam)
I can fake mouse movement to an unfocused application, without effecting my real mouse.
How can I get my current "fake mouse" position if win32api.GetCursorPos()
returns the position of my real mouse cursor?
Edit #1:
I am using WM_MOUSEMOVE
on an external application, thus the only thing I have is the application's window handle
(HWND).
You can use
GetMessagePos
:More reference: Possible to do MouseMove actions with PostMessage without hijacking the cursor?
Edit
If you only want to get its messages through the HWND of the external application, you need to use
SetWindowsHookEx
and make it into a dll to inject it into the external process.You can use
SetWindowsHookEx
function, withWH_CALLWNDPROC
or some other type of hook, and here is an example.