无法从pywinauto的组合框中检索选定的文本

时间:2019-05-23 06:23:59

标签: pywinauto

无法从pywinauto的“组合”框中检索选定的文本,并且连续尝试在无限循环中单击“主页”和“字体”下拉组合框

'''self.app = Application(backend='uia').start(r'C:\Program Files (x86)\Microsoft Office\Office15\winword.exe')

self.app.wait_cpu_usage_lower(threshold=5) # wait until CPU usage is lower than 5%
self.main = self.app.window(title_re='.* - Word')

self.main.Home_tab.select()
self.main.Ribbon.print_control_identifiers()
print(self.main.child_window(title="Font:", control_type="Edit").selected_text())

also tried with below code as well

font= self.main.Edit1.wrapper_object()
combo = ComboBoxWrapper(font)
print(combo.selected_text())
'''

打印控件标识符

| | | | | | | | | GroupBox - 'Font' (L158, T51, R421, B142)
| | | | | | | | | ['GroupBox3', 'FontGroupBox', 'Font']
| | | | | | | | | child_window(title="Font", control_type="Group")
| | | | | | | | | |
| | | | | | | | | | ComboBox - 'Font:' (L162, T61, R256, B84)
| | | | | | | | | | ['Font:', 'Font:ComboBox', 'ComboBox', 'ComboBox0', 'ComboBox1']
| | | | | | | | | | child_window(title="Font:", control_type="ComboBox")
| | | | | | | | | | |
| | | | | | | | | | | Edit - 'Font:' (L163, T63, R242, B82)
| | | | | | | | | | | ['6', 'Edit', 'Edit0', 'Edit1']
| | | | | | | | | | | child_window(title="Font:", control_type="Edit")
| | | | | | | | | | |
| | | | | | | | | | | Button - 'Open' (L242, T61, R256, B84)
| | | | | | | | | | | ['Open', 'Button14', 'OpenButton', 'Open0', 'Open1', 'OpenButton0', 'OpenButton1']
| | | | | | | | | | | child_window(title="Open", control_type="Button")
| | | | | | | | | |
| | | | | | | | | | ComboBox - 'Font Size:' (L256, T61, R299, B84)
| | | | | | | | | | ['Font Size:', 'Font Size:ComboBox', 'ComboBox2']
| | | | | | | | | | child_window(title="Font Size:", control_type="ComboBox")
| | | | | | | | | | |
| | | | | | | | | | | Edit - 'Font Size:' (L257, T63, R285, B82)
| | | | | | | | | | | ['7', 'Edit2']
| | | | | | | | | | | child_window(title="Font Size:", control_type="Edit")
| | | | | | | | | | |
| | | | | | | | | | | Button - 'Open' (L285, T61, R299, B84)
| | | | | | | | | | | ['Open2', 'Button15', 'OpenButton2']
| | | | | | | | | | | child_window(title="Open", control_type="Button")

0 个答案:

没有答案