Python - 小玩意 - 当前鼠标位置
import os
import time
import pyautogui as pag
try:
while True:
print("按下Ctrl + C 结束程序")
# pag.position()返回鼠标的坐标
x, y = pag.position()
posStr = "当前鼠标位置:" + str(x).rjust(4) + ',' + str(y).rjust(4)
# 打印当前鼠标位置坐标
print(posStr)
time.sleep(1)
# 清除屏幕
os.system('cls')
except KeyboardInterrupt:
print('已退出')
还没有评论,来说两句吧...