pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn/simple
$ cat opencv.py
import pyautogui
from pyautogui import size
from pyautogui import position
from pyautogui import moveTo
from pyautogui import click
from pyautogui import doubleClick
import time
# 截取整个屏幕并保存为文件
screenshot = pyautogui.screenshot()
screenshot.save('entire_screen.png')
try:
#aaa4.png为桌面图标图片信息
oneLocation = pyautogui.locateOnScreen('F:\win.png',confidence=0.8)
except Exception as e:
print("ERROR:未找到对应图标")
else:
#进行点击操作
center = pyautogui.center(oneLocation)
print(center)
click(center,button='left',duration=1)
time.sleep(1)
pyautogui.press('enter')
time.sleep(2)
text = 'hello word!\n'
secs_between_keys = 0.1
pyautogui.typewrite(message=text, interval=secs_between_keys)
finally:
print('执行结束')