Python pyautogui 图像定位

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)

学习笔记~

  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值