'How to get real mouse movement, not based on cursor position (python)
Im using windows and python
So I want to make a macro in a game, but the game always centers your mouse at the center of the screen. Every mouse movement algorithm only detects movements based on the difference between the previous cursor and the current cursor. Is there a way to detect mouse movement instead of cursor position?
Solution 1:[1]
Mouse movement is an event. So this event needs to be captured. Windows sends a WM_MOUSEMOVE message when the mouse moves. Various Python extensions can work with this event. E.g. tkinter does this as follows:
import tkinter as tk
root = tk.Tk()
def motion(event):
print('the mouse moved')
root.bind('<Motion>', motion)
root.mainloop()
When the mouse moves in the open window, it is reported that the mouse has moved. Are you looking for something like that?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Martin Finke |