I'm trying to automate a sub window (Dialog with ClassName is #32770) by using UI Automation C# API.
The target sub window shows up in Spy++ and Inspect.exe, but doesn't show in VisualUIAVerifyNative. It also could not be accessed by either AutomationElement.FindFirst or TreeWalker navigation.
I checked the tree in VisualUIAVerifyNative, found it was quite different from the tree in Spy++ and Inspect.exe.
Interesting things:
- My C# code seems behave exactly like VisualUIAVerifyNative.
- I'm able to use AutomationElement.FromHandle to bind the HWND of the Dialog
Do you know why this happens?
Here's the detail of The Dialog from Insepct.exe
How found: Selected from tree...
Name: "V6"
ControlType: UIA_PaneControlTypeId (0xC371)
LocalizedControlType: "Dialog"
BoundingRectangle: {l:-47997 t:-47997 r:-46107 b:-47553}
IsEnabled: true
HasKeyboardFocus: false
ProcessId: 15496
RuntimeId: [2A.140BD8]
FrameworkId: "Win32"
ClassName: "#32770"
NativeWindowHandle: 0x140BD8
IsControlElement: false
IsContentElement: false
ProviderDescription: "[pid:10556,hwnd:0x140BD8 Main:Microsoft: Container Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
LegacyIAccessible.ChildId: 0
LegacyIAccessible.Name: "V6"
LegacyIAccessible.Role: Dialog (0x12)
LegacyIAccessible.State: (0x100000)
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: false
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
...
Just found this https://stackoverflow.com/a/14187618/1633272.
I tried the TreeWalker.RawViewWalker, it worked. However TreeWalker.ControlViewWalker didn't.