我正在尝试使用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)
是这样的。我如何获得价值?
答案 0 :(得分:1)
这可能是这样的:
label.child_window(auto_id="debugConsole", control_type="Edit").iface_value.GetValue()
它将在以后的版本中作为.get_value()
方法添加。