赞
踩
import pyautogui import time # 全屏截图 # pyautogui.screenshot('./img01.png') # img = pyautogui.screenshot() # img.save('./img02.png') # 区域截图 # pyautogui.screenshot('./img03.png', (32, 68, 274, 607)) # 传入左上角xy坐标,右下角xy坐标 # # 获取图片在当前的屏幕的位置信息 # res = pyautogui.locateOnScreen('./test01.png') # print(res) # # 获取区域的中心坐标 # x, y = pyautogui.center(res) # print(x, y) # # # 模拟点击 # pyautogui.click(x, y) # 一步获取中心坐标 # x, y = pyautogui.locateCenterOnScreen('./test01.png') # print(x, y) # pyautogui.click(x, y) # 匹配屏幕所有的图片目标 # imgs = pyautogui.locateAllOnScreen('./test02.png') # for i in imgs: # print(i) # 设置图像识别的超时时间、信任度、灰度 # res = pyautogui.locateOnScreen('./test03.png', minSearchTime=5)# 超时时间 # print(res) # # 设置信任度 # res = pyautogui.locateOnScreen('./test03.png', minSearchTime=5, confidence=0.5) # print(res) # 灰度匹配 (以黑白对比) res = pyautogui.locateOnScreen('./test03.png', minSearchTime=5, confidence=0.8, grayscale=True) print(res)
学习笔记~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。