'HwndElementInfo' object 没有属性 'automation_id'

'HwndElementInfo' object has no attribute 'automation_id'

我正在尝试使用 pywinauto 查找 child window,但没有成功,并收到问题标题中所述的错误。

代码

wnd_spec.child_window(control_type='UIA_PaneControlTypeId (0xC371)', auto_id='PanelFields')

Inspect.exe

Name: ""
ControlType: UIA_PaneControlTypeId (0xC371)
LocalizedControlType: "pane"
AutomationId: "PanelFields"
FrameworkId: "WinForm"

我running/connecting使用后端=win32 的应用程序以避免 NoPatternInterface 错误。

任何帮助将不胜感激

这在 pywinauto==0.6.5 中实现。现在您也可以使用 auto_idcontrol_type 搜索属性来搜索 "win32" 后端。它应该可以正常工作,尤其是对于 WinForms 应用程序。

P.S。当然,control_type 属性 值看起来比 Inspect.exe 显示的更简单。请依赖 print_control_identifiers() 输出。