Pywinauto:RuntimeError:我们永远不应该到达ListView.get_item()的这一部分

时间:2017-05-31 16:23:26

标签: pywinauto

我正在尝试使用pywinauto从我的Windows应用程序中获取对话框的listview控件中的文本。以下是代码段和错误。

*from pywinauto.application import Application  
app = Application().connect(handle=0x00C21210)  
dlg = app.window(handle=0x00D70EDE)  
dlg.ListView.texts()*  

**Error:** RuntimeError: We should never get to this part of ListView.get_item(), retval = 0, GetLastError() = 0, item_index = 0, subitem_index = 0  

以下是print_control_identifiers为该对话框控件返回的内容

   | ListView - ''    (L49, T162, R785, B530)  
   | ['ListView', u'Rate File Path:ListView']  
   | child_window(class_name="WindowsForms10.SysListView32.app.0.378734a")  
   |    |  
   |    | Header - ''    (L51, T164, R783, B181)  
   |    | [u'Rate File Path:Header', 'Header']  
   |    | child_window(class_name="SysHeader32")  

我还编辑了这篇文章,以获得如下的inspect.exe结果:

How found:  Mouse move (480,279)  
    hwnd=0x008615AA 64bit class="WindowsForms10.SysListView32.app.0.378734a" style=0x56010141 ex=0x200  
ControlType:    UIA_ListControlTypeId (0xC358)  
LocalizedControlType:   "list"  
BoundingRectangle:  {l:23 t:136 r:759 b:504}  
IsEnabled:  true  
IsOffscreen:    false  
IsKeyboardFocusable:    true  
HasKeyboardFocus:   true  
ProcessId:  25412  
RuntimeId:  [2A.8615AA]  
AutomationId:   "8787370"  
FrameworkId:    "WinForm"  
ClassName:  "WindowsForms10.SysListView32.app.0.378734a"  
NativeWindowHandle: 0x8615AA  
ProviderDescription:    "[pid:26132,hwnd:0x8615AA Annotation:Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll); Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"  
IsPassword: false  
FillColor:  [Not supported]
OutlineColor:   [Not supported]
OutlineThickness:   [Not supported]
FillType:   [Not supported]
CenterPoint:    [Not supported]
Rotation:   [Not supported]
Size:   [Not supported]
VisualEffects:  [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.Role: list (0x21)
LegacyIAccessible.State:    focused,focusable (0x100004)
Selection.CanSelectMultiple:    false
Selection.IsSelectionRequired:  true
Selection.Selection:    
IsAnnotationPatternAvailable:   false
IsDragPatternAvailable: false
IsDockPatternAvailable: false
IsDropTargetPatternAvailable:   false
IsExpandCollapsePatternAvailable:   false
IsGridItemPatternAvailable: false
IsGridPatternAvailable: false
IsInvokePatternAvailable:   false
IsItemContainerPatternAvailable:    false
IsLegacyIAccessiblePatternAvailable:    true
IsMultipleViewPatternAvailable: false
IsObjectModelPatternAvailable:  false
IsRangeValuePatternAvailable:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    true
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
IsTableItemPatternAvailable:    false
IsTablePatternAvailable:    false
IsTextChildPatternAvailable:    false
IsTextEditPatternAvailable: false
IsTextPatternAvailable: false
IsTextPattern2Available:    false
IsTogglePatternAvailable:   false
IsTransformPatternAvailable:    false
IsTransform2PatternAvailable:   false
IsValuePatternAvailable:    false
IsVirtualizedItemPatternAvailable:  false
IsWindowPatternAvailable:   false
IsCustomNavigationPatternAvailable: false
FirstChild: (null) header
LastChild:  (null) list item
Next:   "X" button
Previous:   "Y" button
Other Props:    Object has no additional properties
Children:   (null) header
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
    (null) list item
Ancestors:  "A" window
    "Workspace" pane
    "C" window
    "Desktop" pane
    [ No Parent ]

1 个答案:

答案 0 :(得分:0)

您需要安装64位Python + pywinauto。它可以自动化32位和64位应用程序。或者使用Application(backend="uia")和Inspect.exe作为间谍工具。对于WinForms应用程序可能更好,并且不限制您使用64位Python。

P.S。我将尝试重现它并在下一版本中添加更明确的错误消息。