from ctypes import windll, Structure, c_long, byref class POINT(Structure): _fields_ = [("x", c_long), ("y", c_long)] def queryMousePosition(): pt = POINT() windll.user32.GetCursorPos(byref(pt)) return { "x": pt.x, "y": pt.y} pos = queryMousePosition() print(pos)
References
https://stackoverflow.com/questions/3698635/getting-cursor-position-in-python