找回密码
 立即注册
搜索
到手67.99元!阿里云轻量2核2G云服务器
查看: 16|回复: 0

pyautogui实时获取鼠标位置

[复制链接]

696

主题

0

回帖

11

积分

管理员

积分
11
发表于 2026-5-23 10:31:02 | 显示全部楼层 |阅读模式
import pyautogui
import time

def get_mouse_position():
    try:
        while True:
            x, y = pyautogui.position()
            print(f"\r当前鼠标坐标: X={x} Y={y}", end="", flush=True)
            time.sleep(0.1)
    except KeyboardInterrupt:
        print("\n已停止监控")

if __name__ == "__main__":
    time.sleep(3)
    get_mouse_position()
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|skypiea

GMT+8, 2026-6-25 03:43 , Processed in 0.041632 second(s), 20 queries .

Powered by skypiea

快速回复 返回顶部 返回列表