一. 环境
根据官网文档: https://pywinauto.readthedocs.io/en/latest/index.html , pywinauto库依赖以下:
之后执行 pip install pywinauto
即完成安装
另外, 需要下载元素定位软件 Inspector.exe, 在 https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/master/inspect/InspectX64.exe 中下载或自行百度
二.基本操作示例
# 获取 Desktop实例
app = pywinauto.Desktop()
# 通过弹窗名称获取窗口对象 (WindowSpecification)
win = app['打开']
# 获取弹窗对象下所有控件的属性
win.print_control_identifiers(depth=None, filename=None)