public ControlElement(WindowInfo parentWindow, ConditionBase findCondition, AutomationElementInfo info, OurAutomation automation) : base(automation) { mInfo = info ?? throw new ArgumentNullException(nameof(info)); mParentWindow = parentWindow ?? throw new ArgumentNullException(nameof(parentWindow)); mFindCondition = findCondition ?? throw new ArgumentNullException(nameof(findCondition)); Patterns = new ControlElementPatterns(this); }
/// <summary> /// Returns a tree of information objects which shows the whole tree below the given object. /// </summary> /// <param name="element">The parent object from which all child elements have to be read.</param> /// <returns>The given element as an information object wich all its children in a tree.</returns> public static AutomationElementInfo GetFullUITree(AutomationElement element) { var rootElementInfo = new AutomationElementInfo(element); LogPool.Append("Read full UI tree down from '{0}'.", rootElementInfo); Read(rootElementInfo); return(rootElementInfo); }
private static void Read(AutomationElementInfo rootElement) { foreach (var child in GetChildren(rootElement.AutomationElement)) { var childElementInfo = new AutomationElementInfo(child); rootElement.Children.Add(childElementInfo); Read(childElementInfo); } }
public static AutomationElementInfo Create(Control control) { var xResultItem = new AutomationElementInfo(); xResultItem.Name = control.Name; xResultItem.Height = control.Bounds.Height; xResultItem.Width = control.Bounds.Width; var xStartPos = control.PointToScreen(new Point(0, 0)); xResultItem.PositionOnDesktopX = xStartPos.X; xResultItem.PositionOnDesktopY = xStartPos.Y; var xButton = control as Button; if (xButton != null) { xResultItem.InvokePattern = new InvokePatternInfo(); } return(xResultItem); }