public int Find(String className, String name, int index) { AutomationElementCollection elements = Root.FindAll(TreeScope.Children, CustomConditions.ByName(name)); if (elements.Count <= index) { return(0); } AutomationElement element = elements[index]; return(element.Current.NativeWindowHandle); }
public int Find(int parent, String className, String name, int index) { AutomationElement baseElement = Find(parent); if (baseElement == null) { return(0); } AutomationElementCollection elements = baseElement.FindAll(TreeScope.Subtree, CustomConditions.ByName(name)); if (elements.Count <= index) { return(0); } AutomationElement element = elements[index]; return(element.Current.NativeWindowHandle); }