listbox - 如何使用 pywinauto 选中/取消选中 ListBox 中的项目?
问题描述
我正在尝试使用 pywinauto 自动化 Cambium LINKPlanner 应用程序,并找到了几乎所有我需要的控件。但是,有一个带有标识符“ListBox”的选中列表框,似乎没有任何方法可以选中/取消选中列表中的项目。
我可以列出 ListBox 的内容:
>>> app.LINKPlanner.ListBox.item_texts()
['PMP 450b High Gain', 'PMP 450b Mid-gain', 'PMP450 (retired)', 'PMP450d (retired)', 'PMP450i', 'PMP450i ATEX/HAZLOC']
我可以通过名称或位置突出显示 ListBox 中的项目:
>>> app.LINKPlanner.ListBox.select('PMP450i')
<win32_control.ListBoxWrapper - '', ListBox, 70154>
>>> app.LINKPlanner.ListBox.select(2)
<win32_control.ListBoxWrapper - '', ListBox, 70154>
但我无法选中/取消选中列表项中的复选框。
有什么建议么?
编辑:
使用 Vasily 的建议,我能够看到边界框,然后使用 click_input 单击复选框。
>>> app.LINKPlanner.ListBox.select('PMP 450b High Gain').item_rect(0)
<RECT L0, T0, R276, B17>
>>> app.LINKPlanner.ListBox.select('PMP 450b High Gain').click_input(coords=(9,9))
解决方案
如果检测为ListBox,则可能是自绘复选框,无法单独检测。我建议使用 method.item_rect(item_name)
然后 method .click_input()
。方法.client_to_screen()
也可能有帮助。
推荐阅读
- editor - 是否有任何免费的、编码友好的文本编辑器,具有类似于 Microsoft-Word 样式导航窗格的功能?
- python - 我正在尝试从网站 https://animaldiversity.org/accounts/Callithrix%20humilis 从
- next.js - 构建 Next.js 项目时出错:无法加载配置“react-app”以扩展自
- bash - Bash Script如何获取第二个属性及其具体值
- node.js - 带有字符 '、" 或 & 的内容可能需要用三个括号进行转义
- php - $_GET 总是给出 1
- angular - Angular Mat-Table 如何跨越标题行
- r - 没有重复 ID 的分层随机抽样
- r - 无法对接 RStudio Shiny 项目,包 rgdal 出错
- heroku - 在heroku上运行二进制文件时出现分段错误