How to print out 'Live' mouse position coordinates using pyautogui?

笑着哭i 提交于 2020-11-27 08:17:38

问题


I used lots of different source codes, and even copied and pasted but I keep getting random symbols that shift when i move my mouse over them here is my code...

import pyautogui, time, sys
print('Press Ctrl-C to quit.')
try:
    while True:
        CurserPos = pyautogui.position()
        print('\b' * len(CurserPos), end='\r')
        sys.stdout.flush()

I will show the output as an image. I am rather new to Python and would really appreciate some expert advice. Thanks


回答1:


Code :

import pyautogui
pyautogui.displayMousePosition()

Here is some output :

Press Ctrl-C to quit.
X:  0 Y: 1143 RGB: ( 38,  38,  38)

Here is the video where this is being demonstrated https://youtu.be/dZLyfbSQPXI?t=809



来源:https://stackoverflow.com/questions/44533241/how-to-print-out-live-mouse-position-coordinates-using-pyautogui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!