python-3.x - pywinauto - 在对话框/弹出窗口中查找/读取不属于对话框任何控件的文本
问题描述
我正在尝试从应用程序的对话框/弹出窗口下方读取文本“此返回到期日或之前”,我正在尝试使用 pywinauto 进行一些自动化,我能够在此弹出窗口上自动执行其他控件,即OK/Close/etc.,只是无法进入“文本”,我已经尝试了下面的代码,但似乎这个文本不是对话框的任何控制的一部分,所以有没有其他方法可以进入文本? 对话框/弹出
Inspect.exe 显示此弹出窗口inspect_exe_data
到目前为止,我已经尝试过以下代码:
from pywinauto.application import Application
app = Application(backend="win32").start("app.exe")
#This is the dialog with the text i am after
dialog=app.RTI
dialog.window_text()
dialog.texts()
dialog.print_control_identifiers()
dialog.children()
dialog.descendants()
for child in dialog.descendants():
print (child.window_text())
print (child.texts())
输出:
>>> dialog.window_text()
'RTI'
>>> dialog.texts()
['RTI']
>>> dialog.print_control_identifiers()
Control Identifiers:
Tdlg_askbox - 'RTI' (L711, T344, R1208, B482)
['Tdlg_askbox', 'RTI', 'RTITdlg_askbox']
child_window(title="RTI", class_name="Tdlg_askbox")
|
| ComboBox - '' (L723, T503, R1196, B535)
| ['RTIComboBox', 'ComboBox']
| child_window(class_name="TComboBox")
|
| Edit - '' (L723, T465, R1196, B497)
| ['Edit', 'RTIEdit']
| child_window(class_name="TEdit")
|
| CheckBox - 'Don't ask me this again' (L723, T641, R1196, B667)
| ['CheckBox', "Don't ask me this againCheckBox", "Don't ask me this again"]
| child_window(title="Don't ask me this again", class_name="TCheckBox")
|
| Button - 'Help' (L843, T432, R956, B470)
| ['Help', 'HelpButton', 'Button', 'Button0', 'Button1']
| child_window(title="Help", class_name="TButton")
|
| Button - 'Cancel' (L723, T596, R836, B634)
| ['Cancel', 'CancelButton', 'Button2']
| child_window(title="Cancel", class_name="TButton")
|
| Button - 'OK' (L963, T432, R1076, B470)
| ['OK', 'Button3', 'OKButton']
| child_window(title="OK", class_name="TButton")
|
| Button - '&No' (L963, T551, R1076, B589)
| ['&NoButton', 'Button4', '&No']
| child_window(title="&No", class_name="TButton")
|
| Button - '&Yes' (L843, T551, R956, B589)
| ['&Yes', '&YesButton', 'Button5']
| child_window(title="&Yes", class_name="TButton")
>>> dialog.children()
[<win32_controls.ComboBoxWrapper - '', ComboBox, 265638>, <win32_controls.EditWrapper - '', Edit, 265636>, <win32_controls.ButtonWrapper - 'Don't ask me this again', CheckBox, 265634>, <win32_controls.ButtonWrapper - 'Help', Button, 265632>, <win32_controls.ButtonWrapper - 'Cancel', Button, 265630>, <win32_controls.ButtonWrapper - 'OK', Button, 265628>, <win32_controls.ButtonWrapper - '&No', Button, 265626>, <win32_controls.ButtonWrapper - '&Yes', Button, 265624>]
>>> dialog.descendants()
[<win32_controls.ComboBoxWrapper - '', ComboBox, 265638>, <win32_controls.EditWrapper - '', Edit, 265636>, <win32_controls.ButtonWrapper - 'Don't ask me this again', CheckBox, 265634>, <win32_controls.ButtonWrapper - 'Help', Button, 265632>, <win32_controls.ButtonWrapper - 'Cancel', Button, 265630>, <win32_controls.ButtonWrapper - 'OK', Button, 265628>, <win32_controls.ButtonWrapper - '&No', Button, 265626>, <win32_controls.ButtonWrapper - '&Yes', Button, 265624>]
>>> for child in dialog.descendants():
... print (child.window_text())
... print (child.texts())
...
['']
['', '']
Don't ask me this again
["Don't ask me this again"]
Help
['Help']
Cancel
['Cancel']
OK
['OK']
&No
['&No']
&Yes
['&Yes']
解决方案
推荐阅读
- scheme - 在文字之前匹配任意数量的模式变量的方案语法规则?
- python - 如何优化用其他栅格区域平均值替换栅格 nan 值的 Python 循环
- java - 将多个整数值混淆为固定长度值并读回
- regex - 如何让 Google 表格搜索范围并返回“部分重复”的所有行
- python - Seaborn barplot - 没有估计器参数的列值
- django - 如何为每个模型条目(Django)存储和呈现 Pandas 数据帧/CSV?
- mysql - 从 MySQL 到 NodeJS 的 DATE 更改
- c++ - 从 C++ 中的多个向量打印第一个值
- python - Python - 查找按第三列分组的列中两个事件之间的平均差异
- regex - Apache rewriter - 无扩展名文件的复杂重写器