public static List <AutomationElement> FindAdditionElements(List <IElement> oldChildren, AutomationElementCollection newChildren, Dictionary <AutomationElement, IElement> mappingElements) { if (oldChildren == null || oldChildren.Count == 0) { AutomationElement[] arr = new AutomationElement[newChildren.Count]; newChildren.CopyTo(arr, 0); return(arr.ToList()); } List <AutomationElement> re = new List <AutomationElement>(); foreach (IElement oldChild in oldChildren) { AutomationElement automationElement = null; foreach (KeyValuePair <AutomationElement, IElement> pair in mappingElements) { if (pair.Value == null) { continue; } if (pair.Value.Equals(oldChild)) { automationElement = pair.Key; } } if (automationElement != null && !IsElementExisted(newChildren, automationElement)) { re.Add(automationElement); } } return(re); }
public static List <AutomationElement> SearchListAutomationElementsOnlyMatchId(IElement element, AutomationElement rootAutoElement) { Condition idCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, element.Attributes.DesignedId); AutomationElementCollection listElements = rootAutoElement.FindAll(TreeScope.Subtree, idCondition); AutomationElement[] re = new AutomationElement[listElements.Count]; listElements.CopyTo(re, 0); return(re.ToList()); }
public List <AutomationElement> GetChildren(AutomationElement parent) { System.Windows.Automation.Condition findCondition = new PropertyCondition(AutomationElement.IsControlElementProperty, true); AutomationElementCollection children = parent.FindAll(TreeScope.Children, findCondition); AutomationElement[] elementArray = new AutomationElement[children.Count]; children.CopyTo(elementArray, 0); return(elementArray.ToList()); }
public void CopyTo(Array array, int index) { var elements = new AutomationElement[Count]; AutomationElementCollection.CopyTo(elements, 0); for (int i = 0; i < elements.Length; i++) { array.SetValue(new AutomationWrapper(elements[i]), i + index); } }
public static List <AutomationElement> SearchListAutomationElements(IElement element, AutomationElement rootAutoElement) { IdAndNameDesignCondition idAndNameCondition = new IdAndNameDesignCondition(element.Attributes.DesignedId, element.Attributes.DesignedName); Condition idCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, idAndNameCondition.DesignId); Condition nameCondition = new PropertyCondition(AutomationElement.NameProperty, idAndNameCondition.DesignName); AndCondition condition = new AndCondition(idCondition, nameCondition); AutomationElementCollection listElements = rootAutoElement.FindAll(TreeScope.Subtree, condition); AutomationElement[] re = new AutomationElement[listElements.Count]; listElements.CopyTo(re, 0); return(re.ToList()); }
public static List <AutomationElement> FindAdditionElements(AutomationElementCollection _old, AutomationElementCollection _new) { if (_new == null) { return(null); } if (_old == null) { AutomationElement[] temp = new AutomationElement[_new.Count]; _new.CopyTo(temp, 0); return(temp.ToList <AutomationElement>()); } List <AutomationElement> re = new List <AutomationElement>(); foreach (AutomationElement ele in _new) { if (!IsElementExisted(_old, ele)) { re.Add(ele); } } return(re); }
// </Snippet116> void MiscellaneousCalls(AutomationElement element) { String s = element.Current.Name; // <Snippet111> // element is an AutomationElement. int[] id = element.GetRuntimeId(); // </Snippet111> // <Snippet112> // element is an AutomationElement. System.Windows.Point pt; bool clickable = element.TryGetClickablePoint(out pt); // </Snippet112> // <Snippet179> // element is an AutomationElement. System.Windows.Point clickablePoint = element.GetClickablePoint(); System.Windows.Forms.Cursor.Position = new System.Drawing.Point((int)clickablePoint.X, (int)clickablePoint.Y); // </Snippet179> // <Snippet114> // element is an AutomationElement. AutomationPattern[] patterns = element.GetSupportedPatterns(); foreach (AutomationPattern pattern in patterns) { Console.WriteLine("ProgrammaticName: " + pattern.ProgrammaticName); Console.WriteLine("PatternName: " + Automation.PatternName(pattern)); } // </Snippet114> // <Snippet115> AutomationProperty[] properties = element.GetSupportedProperties(); foreach (AutomationProperty prop in properties) { Console.WriteLine(prop.ProgrammaticName); Console.WriteLine(Automation.PropertyName(prop)); } // </Snippet115> // <Snippet113> // element is an AutomationElement. object objPattern; SelectionPattern selPattern; if (true == element.TryGetCurrentPattern(SelectionPattern.Pattern, out objPattern)) { selPattern = objPattern as SelectionPattern; } // </Snippet113> AutomationElementCollection elementCollection = FindByMultipleConditions(MainWindowElement); // <Snippet117> // elementCollection is an AutomationElementCollection. AutomationElement[] elementArray = new AutomationElement[elementCollection.Count]; elementCollection.CopyTo(elementArray, 0); // </Snippet117> // <Snippet118> // elementCollection is an AutomationElementCollection. object[] elementUntypedArray = new object[elementCollection.Count]; elementCollection.CopyTo(elementUntypedArray, 0); // </Snippet118> AutomationElement elementElement = elementCollection[0]; // <Snippet201> AutomationElementCollection desktopChildren = AutomationElement.RootElement.FindAll( TreeScope.Children, Condition.TrueCondition); // </Snippet201> // <Snippet182> // desktopChildren is a collection of AutomationElement objects. AutomationElement firstWindow; try { firstWindow = desktopChildren[0]; } catch (IndexOutOfRangeException) { Console.WriteLine("No AutomationElement at that index."); } // </Snippet182> }