简体   繁体   中英

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM