Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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
:
Retrieves the cursor position for the last message retrieved by the
GetMessage
function.
More reference:
Possible to do MouseMove actions with PostMessage without hijacking the cursor?
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, with
WH_CALLWNDPROC
or some other type of hook, and
here
is an example.
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.