Get image or screen capture in PyWinAuto

71 Views Asked by At

I'm currently using PyWinAuto to get the data from a FileEditor like this.

app = Application(backend='uia').connect(title='AppTitle', timeout=2)
dlg = app.top_window()
list_child = dlg.child_window(auto_id="dgFileEditor", control_type="DataGrid").children()

for item in list_child:
    for cell in item.children():
        for smaller_cell in cell.children():
            element_info = smaller_cell.window_text()
            print(element_info)

The problem I'm facing is the data I get must be verified, which has a little checkmark icon like this. But I'm unable to find the checkmark icon in the Inspect.exe, when I hover in the icon, it show in the Inspect.exe as a DataGridCell with no children or parent. Here is the image of the dataframe with the checkmark. And here is the output on Inspec.exe when I hover in the Icon.

How found:  Mouse move (3128,628)
    hwnd=0x0000000000230A20 32bit class="HwndWrapper[SmartTrans.exe;;9f06b796-7f7e-4981-92a6-680f950e21e7]" style=0x17CF0000 ex=0x4Name:    "Item: SmartTrans.Model.SegmentElement, Column Display Index: 4"
ControlType:    UIA_CustomControlTypeId (0xC369)
LocalizedControlType:   "data grid cell"
BoundingRectangle:  {l:3101 t:601 r:3139 b:646}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AcceleratorKey: ""
AccessKey:  ""
ProcessId:  9748
RuntimeId:  [7.2614.20C235B]
AutomationId:   ""
FrameworkId:    "WPF"
ClassName:  "DataGridCell"
IsControlElement:   true
IsContentElement:   true
ProviderDescription:    "[pid:9748,providerId:0x0 Main(parent link):Unidentified Provider (managed:MS.Internal.Automation.ElementProxy, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)]"
LiveSettingProperty:    Off (0)
IsPassword: false
ItemStatus: ""
ItemType:   ""
IsRequiredForForm:  false
HelpText:   ""
ClickablePoint: {x:3120 y:623}
Orientation:    0
IsDialog:   false
HeadingLevel:   HeadingLevel_None (0x138B2)
GridItem.Column:    4
GridItem.ColumnSpan:    1
GridItem.ContainingGrid:    "" datagrid
GridItem.Row:   67
GridItem.RowSpan:   1
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    "Press"
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "Item: SmartTrans.Model.SegmentElement, Column Display Index: 4"
LegacyIAccessible.Role: push button (0x2B)
LegacyIAccessible.State:    focusable (0x100000)
LegacyIAccessible.Value:    ""
Value.IsReadOnly:   false
Value.Value:    ""
Table.ItemColumnHeaderItems:    
Table.ItemRowHeaderItems:   
IsAnnotationPatternAvailable:   false
IsDragPatternAvailable: false
IsDockPatternAvailable: false
IsDropTargetPatternAvailable:   false
IsExpandCollapsePatternAvailable:   false
IsGridItemPatternAvailable: true
IsGridPatternAvailable: false
IsInvokePatternAvailable:   true
IsItemContainerPatternAvailable:    false
IsLegacyIAccessiblePatternAvailable:    true
IsMultipleViewPatternAvailable: false
IsObjectModelPatternAvailable:  false
IsRangeValuePatternAvailable:   false
IsScrollItemPatternAvailable:   true
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
IsTableItemPatternAvailable:    true
IsTablePatternAvailable:    false
IsTextChildPatternAvailable:    false
IsTextEditPatternAvailable: false
IsTextPatternAvailable: false
IsTextPattern2Available:    false
IsTogglePatternAvailable:   false
IsTransformPatternAvailable:    false
IsTransform2PatternAvailable:   false
IsValuePatternAvailable:    true
IsVirtualizedItemPatternAvailable:  false
IsWindowPatternAvailable:   false
IsCustomNavigationPatternAvailable: false
IsSelectionPattern2Available:   false
FirstChild: [null]
LastChild:  [null]
Next:   "Item: SmartTrans.Model.SegmentElement, Column Display Index: 5" data grid cell
Previous:   "Item: SmartTrans.Model.SegmentElement, Column Display Index: 3" data grid cell
Other Props:    Object has no additional properties
Children:   Container has no children
Ancestors:  "SmartTrans.Model.SegmentElement" dataitem
    "" datagrid
    "SmartTrans" window
    "Desktop 1" pane
    [ No Parent ]

I have tried Screencapture and tooltip text but still nothing work. Any help would be appreciated.

0

There are 0 best solutions below