1. 安装
(1)ubuntu20系统下安装
pip3 install pymouse
sudo apt-get install python-xlib
pip3 install PyUserInput
(2)CentOS8、Fedora33系统下安装
pip3 install pymouse --user
pip3 install python-xlib --user
pip3 install PyUserInput --user
(3)试一下
python
from pymouse import PyMouse
exit()
没有错误,即安装成功
2. 写脚本
mouse.sh
#!/usr/bin/python3
import time
from pymouse import PyMouse
m = PyMouse()
m.position()
time.sleep(1)
m.move(100,100)
m.position()
time.sleep(1)
m.click(110,110)
m.position()
time.sleep(1)
m.click(120,120,1)
m.position()
time.sleep(1)
m.click(130,130,2)
m.position()
time.sleep(1)
n = 99
while n > 0:
pos=100+n
m.move(pos,pos)
m.position()
n = n - 2