private AutomationElement ListItemElementFromPoint(AutomationElementFactory factory, Point pt) { if (PInvoke.WindowFromPoint(pt) != Handle) { return(null); } AutomationElement elem = factory.FromPoint(pt); if (elem == null) { return(null); } if (elem.GetClassName() == "UIItem") { return(elem); } elem = elem.GetParent(); if (elem == null) { return(null); } if (elem.GetClassName() == "UIItem") { return(elem); } return(null); }
public static T DoQuery <T>(Query <T> query) { try { return((T)automationDispatch.Invoke(new Func <T>(() => { try { using (AutomationElementFactory factory = new AutomationElementFactory(pAutomation)) { return query(factory); } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, "Automation Thread"); return default(T); } }), DispatcherPriority.Normal)); } catch { return(default(T)); } }
internal AutomationElement(IUIAutomationElement pElement, AutomationElementFactory factory) { this.factory = factory; this.pElement = pElement; factory.AddToDisposeList(this); }