We are trying to automate the click of the next button in the Lync interface. The problem is that we cannot click it securely. Sometimes it works; in other cases this is not so. What we are trying to do is open the Lync options window.
Here are some parts of the problem:
- we use the namespace
System.Windows.Automationto automate the user interface. - we usually call
AutomationElement.FindFirstto get the user interface element - this does not work for a button because there is no ancestor in the button menu
- so we use
TreeWalkerto move all descendantsAutomomationElement.RootElement - using
TreeWalker, we sometimes find a match, but weird and unpredictable sometimes we don’t - using Inspect.exe we see that there are no ancestors in the Context menu
How can we reliably find and press a button?


From inspect.exe
How found: Selected from tree...
Name: ""
ControlType: UIA_MenuItemControlTypeId (0xC35B)
LocalizedControlType: "menu item"
ProcessId: 0
IsControlElement: true
IsContentElement: true
ProviderDescription: "[pid:3084,hwnd:0x0 Annotation:Microsoft: Annotation Proxy (unmanaged:UIAutomationCore.dll); Main(parent link):Microsoft: MSAA Proxy (unmanaged:UIAutomationCore.dll)]"
IsPeripheral: [Not supported]
LiveSettingProperty: [Not supported]
FlowsFrom: [Not supported]
OptimizeForVisualContent: [Not supported]
Annotation.AnnotationAuthor: [Not supported]
Annotation.AnnotationTypeId: [Not supported]
Annotation.Author: [Not supported]
Annotation.DateTime: [Not supported]
Annotation.Target: [Not supported]
Drag.DropEffect: [Not supported]
Drag.DropEffects: [Not supported]
Drag.GrabbedItems: [Not supported]
Drag.IsGrabbed: [Not supported]
DropTarget.DropTargetEffect: [Not supported]
DropTarget.DropTargetEffects: [Not supported]
LegacyIAccessible.ChildId: 3
LegacyIAccessible.Name: ""
ObjectModel.UnderlyingObjectModel: [Error: calling getter for this property: hr=0x80070057 - The parameter is incorrect.]
SpreadsheetItem.AnnotationObjects: [Not supported]
SpreadsheetItem.AnnotationTypes: [Not supported]
SpreadsheetItem.Formula: [Not supported]
Style.ExtendedProperties: [Not supported]
Style.FillColor: [Not supported]
Style.FillPatternColor: [Not supported]
Style.FillPatternStyle: [Not supported]
Style.Shape: [Not supported]
Style.StyleId: [Not supported]
Style.StyleName: [Not supported]
Transform2.CanZoom: [Not supported]
Transform2.ZoomLevel: [Not supported]
Transform2.ZoomMinimum: [Not supported]
Transform2.ZoomMaximum: [Not supported]
IsAnnotationPatternAvailable: [Not supported]
IsDragPatternAvailable: [Not supported]
IsDockPatternAvailable: false
IsDropTargetPatternAvailable: [Not supported]
IsExpandCollapsePatternAvailable: false
IsGridItemPatternAvailable: false
IsGridPatternAvailable: false
IsInvokePatternAvailable: false
IsItemContainerPatternAvailable: false
IsLegacyIAccessiblePatternAvailable: true
IsMultipleViewPatternAvailable: false
IsObjectModelPatternAvailable: [Not supported]
IsRangeValuePatternAvailable: false
IsScrollItemPatternAvailable: false
IsScrollPatternAvailable: false
IsSelectionItemPatternAvailable: false
IsSelectionPatternAvailable: false
IsSpreadsheetItemPatternAvailable: [Not supported]
IsSpreadsheetPatternAvailable: [Not supported]
IsStylesPatternAvailable: [Not supported]
IsSynchronizedInputPatternAvailable: false
IsTableItemPatternAvailable: false
IsTablePatternAvailable: false
IsTextChildPatternAvailable: [Not supported]
IsTextEditPatternAvailable: [Not supported]
IsTextPatternAvailable: false
IsTextPattern2Available: [Not supported]
IsTogglePatternAvailable: false
IsTransformPatternAvailable: false
IsTransform2PatternAvailable: [Not supported]
IsValuePatternAvailable: false
IsVirtualizedItemPatternAvailable: false
IsWindowPatternAvailable: false
FirstChild: [null]
LastChild: [null]
Next: [null]
Previous: [null]
Other Props: Object has no additional properties
Children: [Error: calling getter for this property: hr=0x80004005 - Unspecified error]
Ancestors: "Context" menu
"Context" window
[ No Parent ]
source
share