1、环境配置(下载两个库pyautogui 和opencv-python)
pip install pyautogui
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python(下载超时可以换下面的阿里源)
pip install -i https://mirrors.aliyun.com/pypi/simple/ opencv-python
2、代码编程
import pyautogui
import time
# 取得软件图标的位置
post=pyautogui.locateOnScreen('drew.png')
#移动鼠标到软件图标的相对位置
x,y=pyautogui.center(post)
pyautogui.moveTo(x,y,1)
# 鼠标双击
pyautogui.doubleClick()
# 程序等待2s
time.sleep(2)
#获得向下箭头的坐标
pos =pyautogui.locateOnScreen(image='post_logo.png')
x,y=pyautogui.center(pos)
pyautogui.moveTo(x,y,0.2)#移动的时间间隔为0.2s
#鼠标左单击
pyautogui.leftClick()
#移动鼠标找到心形的图标
pos2 =pyautogui.locateOnScreen(image='xing.png')
x,y=pyautogui.center(pos2)
pyautogui.moveTo(x,y,0.2)
pyautogui.leftClick()
#移动鼠标到指定位置,duration为时间间隔
pyautogui.mouseDown(x=207,y=297,button='primary',durat