I tried this How to get the text cursor position in Windows?, but it still not work, when mouse leaves gui's boundingbox, it does not update mouse position anymore What I want to do is to let mouse move out my python app's area, and let it move on other part of the screen, and get the position of it relative to the screen
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)