Oatmeal556 Oatmeal556 - 1 year ago 130
Python Question

Python Trouble getting cursor position (x, y) on desktop

I've been looking for ways to find my cursor position and put it on to two variables, x and y. But most answers are outdated and i can't seem to make them work. I would rather if it is in pythons standard librarys or pywinauto. I would also prefer in python 2.7. Thanks.

Answer Source

You can do this with PyMouse.

>>> import pymouse;
>>> mouse = pymouse.PyMouse()
>>> mouse.position()
(288.046875, 396.15625)
>>> mouse.position()
(0.0, 0.0)
>>> mouse.position()
(1439.99609375, 861.2890625)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download