一、安装pyautogui
pip install pyautogui
二、调用
import time
import random
import pyautogui
三、自动控制鼠标
while 1:
# 15秒钟移动一次鼠标(移动鼠标时间可以根据自己需要设定)
time.sleep(15)
pyautogui.moveTo(x=5100,y=random.randint(1500,1600))
################################移动鼠标
####pyautogui.moveTo()函数将鼠标立即移动到屏幕的指定位置:x,y为坐标,duration指定所需秒数
import pyautogui
for i in range(10):
pyautogui.moveTo(5100,1600,duration=5.25)
pyautogui.moveTo(200,100,duration=5.25)
pyautogui.moveTo(200,200,duration=5.25)
pyautogui.moveTo(100,200,duration=5.25)
####pyautogui.moveRel()函数相对于当前的位置移动鼠标
import pyautogui
for i in range(10):
pyautogui.moveRel(100,0,duration=0.25)
pyautogui.moveRel(0,100,duration=0.25)
pyautogui.moveRel(-100,0,duration=0.25)
pyautogui.moveRel(0,-100,duration=0.25)
####pyautogui.position()函数确定鼠标当前的位置
pyautogui.position()
网友评论