public static string Details(UiElement uiElement) { try { var stringBuilder = new StringBuilder(); var cr = new CacheRequest { AutomationElementMode = AutomationElementMode.None }; // Add the element properties cr.Add(AutomationElementIdentifiers.AutomationIdProperty); cr.Add(AutomationElementIdentifiers.ControlTypeProperty); cr.Add(AutomationElementIdentifiers.NameProperty); cr.Add(AutomationElementIdentifiers.HelpTextProperty); cr.Add(AutomationElementIdentifiers.BoundingRectangleProperty); cr.Add(AutomationElementIdentifiers.ClassNameProperty); cr.Add(AutomationElementIdentifiers.IsOffscreenProperty); cr.Add(AutomationElementIdentifiers.FrameworkIdProperty); cr.Add(AutomationElementIdentifiers.ProcessIdProperty); // Add the pattern availability properties cr.Add(AutomationElementIdentifiers.IsDockPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsExpandCollapsePatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsGridPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsGridItemPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsInvokePatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsItemContainerPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsMultipleViewPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsRangeValuePatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsScrollItemPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsScrollPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsSelectionItemPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsSynchronizedInputPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsTablePatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsTableItemPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsTextPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsTogglePatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsTransformPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsValuePatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsVirtualizedItemPatternAvailableProperty); cr.Add(AutomationElementIdentifiers.IsWindowPatternAvailableProperty); cr.TreeScope = TreeScope.Subtree; cr.TreeFilter = Condition.TrueCondition; // Activate the cache request using (cr.Activate()) { // Re-find the root element with caching activated uiElement = uiElement.FindFirst(TreeScope.Element, Condition.TrueCondition); Details(stringBuilder, uiElement, string.Empty); } return(stringBuilder.ToString()); } catch (Exception ex) { Console.WriteLine("Failed to dump info: " + ex); return(string.Empty); } }