1. 安装好Python和pip,并保证二者能够正常使用;
  2. 使用下方命令安装指定版本的​​pyautogui​​库:

pip install pyautogui==0.9.50
  1. 撰写下方代码:
import pyautogui
import random
import time


while True:
x = random.randint(-200, 200)
y = random.randint(-200, 200)
pyautogui.moveRel(x, y)
time.sleep(5)
  1. 运行写入上方代码的脚本,即可看到效果。




作者:艾孜尔江