Loading

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

posted @ 2023-01-20 15:23  拾月凄辰  阅读(289)  评论(0编辑  收藏  举报