我试图使用pywinauto自动化我的应用程序。我想从一个只能读取和聚焦的编辑框中读取值。是否有可能通过pywinauto?
这是我的代码:
dialog = Desktop(backend='uia')
win = dialog.window(title_re ="XXX_Decoder")
label=win.child_window(title="Debug Output",auto_id="debugConsoleGroupBox",control_type="Group")
label.child_window(auto_id="debugConsole", control_type="Edit").texts()
对于win.print_control_identifiers()我得到:
Dialog - 'WRT BT Decoder' (L52, T52, R724, B430)
['WRT BT Decoder', 'Dialog', 'WRT BT DecoderDialog']
child_window(title="WRT BT Decoder", auto_id="WRT_BT_Decoders", control_type="Window")
|
|
| GroupBox - 'Debug Output' (L80, T257, R670, B370)
| ['Debug OutputGroupBox', 'GroupBox', 'Debug Output', 'GroupBox0', 'GroupBox1']
| child_window(title="Debug Output", auto_id="debugConsoleGroupBox", control_type="Group")
| |
| | Edit - '' (L100, T276, R644, B364)
| | ['', 'Edit', '0', '1', 'Edit0', 'Edit1']
| | child_window(auto_id="debugConsole", control_type="Edit")
| | |
| | | ScrollBar - 'Vertical' (L625, T278, R642, B362)
| | | ['ScrollBar', 'VerticalScrollBar', 'Vertical']
| | | child_window(title="Vertical", auto_id="NonClientVerticalScrollBar", control_type="ScrollBar")
| | | |
| | | | Button - 'Line up' (L625, T278, R642, B295)
| | | | ['Line up', 'Line upButton', 'Button2']
| | | | child_window(title="Line up", auto_id="UpButton", control_type="Button")
| | | |
| | | | Button - 'Line down' (L625, T345, R642, B362)
| | | | ['Line downButton', 'Line down', 'Button3']
| | | | child_window(title="Line down", auto_id="DownButton", control_type="Button")
|
在inspect.exe中:
LegacyIAccessible.Name: ""
LegacyIAccessible.Role: editable text (0x2A)
LegacyIAccessible.State: read only,focusable (0x100040)
就是这样。我怎样才能获得价值?
这可能是这样的:
label.child_window(auto_id="debugConsole", control_type="Edit").iface_value.GetValue()
它将在未来版本中作为.get_value()
方法添加。