0
点赞
收藏
分享

微信扫一扫

python 控制鼠标操作

import time
import pyautogui


## 必须以管理员身份运行此程序,不然鼠标点击会没有效果!!!

def moveAndClick():
print("start app")
x, y = 976, 748 # 鼠标需要移动到的位置
print("start moving mouse to ({},{})".format(x, y))
num_seconds = 1 # 将鼠标移动到指定坐标的间隔时间
pyautogui.moveTo(x, y, duration=num_seconds)
time.sleep(1)

# 点击鼠标
print("start click!")
pyautogui.click()


i = 1
while i < 5:
print("第{}次执行:".format(i))
moveAndClick()
print("-" * 30)
time.sleep(3600) # 延迟一个小时
i += 1



举报

相关推荐

0 条评论