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

UIAutomation开发常用方法的参考文档

简介

由于UIAutomation的官方文档只有一个github中的readme文件,只是简单的使用示例,具体使用还需要在代码中查找,非常不方便。经过我多年使用UIAutomation开发的经验和整理,把常用的功能梳理成本文档,作为我的开发参考使用,这样就不用每次都翻代码了,同时也可以使用AI编程时作为参考文档使用

UIAutomation是一个用于Windows UI自动化的Python库,可以用来实现Windows桌面应用程序的自动化控制。它基于Windows UI Automation API,提供了丰富的界面控件操作功能。

主要功能

1. 控件查找

# 获取根控件
root = auto.GetRootControl()

# 获取焦点控件
focused = auto.GetFocusedControl() 

# 获取前台控件
foreground = auto.GetForegroundControl()

# 通过坐标获取控件
control = auto.ControlFromPoint(x, y)

# 通过窗口句柄获取控件
control = auto.ControlFromHandle(hwnd)

# 获取父控件
parent = control.GetParentControl()

# 获取第一个子控件
firstChild = control.GetFirstChildControl()

# 获取最后一个子控件
lastChild = control.GetLastChildControl()

# 获取下一个兄弟控件
nextSibling = control.GetNextSiblingControl()

# 获取上一个兄弟控件
prevSibling = control.GetPreviousSiblingControl()

# 获取所有子控件
children = control.GetChildren()

# 获取祖先控件
ancestor = control.GetAncestorControl(condition)

2. 控件基本操作

# 检查控件是否存在
control.Exists(maxSearchSeconds=5)

# 等待控件消失
control.Disappears(maxSearchSeconds=5)

# 重新查找控件
control.Refind(maxSearchSeconds=5)

# 获取控件位置
rect = control.BoundingRectangle

相关文章:

  • blender bpy渲染禁用日志
  • 尚硅谷爬虫note12
  • 【Electron入门】进程环境和隔离
  • MySQL数据库连接池泄露导致MySQL Server超时关闭连接
  • ESP32学习笔记_Bluetooth(2)——Bluetooth Stack、GAP
  • Node.js 入门 原型链污染
  • Fisher信息矩阵(Fisher Information Matrix, FIM)与自然梯度下降:机器学习中的优化利器
  • PVE虚拟机解除locked(锁定状态)
  • React进阶之前端业务Hooks库(二)
  • 【PDF预览】使用iframe实现pdf文件预览,加盖章
  • mysql 迁移到人大金仓数据库
  • 个性化推荐驱动数字内容体验升级
  • 算法回顾1
  • H5--开发适配
  • TLV解码
  • 多层次自治协作智能网络
  • Ubuntu20.04之VNC的安装使用与常见问题
  • Vue3 + vite 打包后查看资源占比
  • 单片机裸机编程:状态机与其他高效编程框架
  • 神经网络八股(3)
  • 遵义公司做网站找哪个公司好/谷歌推广效果怎么样
  • 信息推广网站点不开的那种怎么做/seo优化收费
  • wordpress常用函数大全/长沙百度网站优化
  • 苏州制作网站的公司/网络营销工程师是做什么的
  • 做网站百度云/网上培训
  • 毕业设计论文网站/成品网站货源1