当前位置:   article > 正文

Python pyautogui 图像定位_pyautogui图片定位

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)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

学习笔记~

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号