当前位置: 首页 > news >正文

pywinauto通过图片定位怎么更加精准的识别图片?

pywinauto通过图片定位怎么更加精准的识别图片?

可以使用置信度的配置,添加了对比图片相似程度达到多少就可以认为是合适的定位图片

import time
from time import sleep
from pywinauto.application import Application
from pywinauto.keyboard import send_keys
from pywinauto import mouse
import pyautogui#判断是否存在
def search_is_exist_image(image_address):try:button_location = pyautogui.locateOnScreen(image_address, confidence=0.8)return button_location is not Noneexcept Exception as e:logger.error(f'Error: {str(e)}')return False#间隔interval秒查询下元素image_address是否存在,超过time秒则停止
def search_is_exist_with_timeout(image_address, timeout, interval):start_time = time.time()while True:if search_is_exist_image(image_address):return Trueif time.time() - start_time > timeout:return Falsetime.sleep(interval)#间隔interval秒查询下多个元素image_address是否存在,超过time秒则停止
def search_is_exist_images_with_timeout(image_address_list, timeout, interval):start_time = time.time()while True:for index,image_address in enumerate(image_address_list):if search_is_exist_image(image_address):return indexif time.time() - start_time > timeout:return Nonetime.sleep(interval)#查找到元素并点击
def search_click(image_address):try:button_location = pyautogui.locateOnScreen(image_address, confidence=0.8)if button_location is not None:button_center = pyautogui.center(button_location)pyautogui.click(button_center) except Exception as e:logger.error(f'Error: {str(e)}')#查找到元素并移动上去
def search_move(image_address):try:button_location = pyautogui.locateOnScreen(image_address, confidence=0.8)if button_location is not None:button_center = pyautogui.center(button_location)pyautogui.moveTo(button_center, duration=0.5) except Exception as e:logger.error(f'Error: {str(e)}')    
http://www.xdnf.cn/news/299719.html

相关文章:

  • 抖音代播领航者——品融电商(PINKROON)的运营实力与服务解析
  • 使用 AddressSanitizer 检测堆越界错误
  • 【CPU占用率查看】
  • 创建简易个人关系图谱(Neo4j )
  • 【落羽的落羽 C++】list及其模拟实现
  • On the Biology of a Large Language Model——论文学习笔记——拒答和越狱
  • 华为私有协议Hybrid
  • 5月6日日记
  • QtGUI模块功能详细说明,图像处理(三)
  • 目标检测(Object Detection)研究方向常用数据集简单介绍
  • 【Bootstrap V4系列】学习入门教程之 组件-卡片(Card)高级用法
  • 数据初步了解
  • 论文速读:《CoM:从多模态人类视频中学习机器人操作,助力视觉语言模型推理与执行》
  • 电池热管理CFD解决方案,为新能源汽车筑安全防线
  • TikTok 矩阵账号运营实操细节:打造爆款矩阵
  • SpringBoot整合Kafka、Flink实现流式处理
  • 三种信号本振
  • Redis 7.0中5种新特性及实战应用
  • 【ArcGISPro】创建要素和刷新数据库后卡顿
  • 浔川AI 第二次内测报告
  • 数据可视化与分析
  • Flutter开发IOS蓝牙APP的大坑
  • 购物数据分析
  • 云境天合水陆安全漏电监测仪—迅速确定是否存在漏电现象
  • OS7.【Linux】基本指令入门(6)
  • FPGA实战项目1——坦克大战
  • HarmonyOS 5.0 分布式数据协同与跨设备同步​​
  • 在sheel中运行Spark
  • 【quantity】0 README.md文件
  • Linux服务之nginx中高级配置