public static AutomationElement FromIAccessible(Accessibility.IAccessible acc, int childId) { Utility.ValidateArgumentNonNull(acc, "acc"); try { UIAutomationClient.IUIAutomationElement element = Automation.Factory.ElementFromIAccessibleBuildCache( (UIAutomationClient.IAccessible)acc, childId, CacheRequest.CurrentNativeCacheRequest); return(AutomationElement.Wrap(element)); } catch (System.Runtime.InteropServices.COMException e) { Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; } } }
void UIAutomationClient.IUIAutomationFocusChangedEventHandler.HandleFocusChangedEvent( UIAutomationClient.IUIAutomationElement sender) { // Can't set the arguments -- they come from a WinEvent handler. AutomationFocusChangedEventArgs args = new AutomationFocusChangedEventArgs(0, 0); _focusHandler(AutomationElement.Wrap(sender), args); }
void UIAutomationClient.IUIAutomationPropertyChangedEventHandler.HandlePropertyChangedEvent( UIAutomationClient.IUIAutomationElement sender, int propertyId, object newValue) { AutomationProperty property = AutomationProperty.LookupById(propertyId); object wrappedObj = Utility.WrapObjectAsProperty(property, newValue); AutomationPropertyChangedEventArgs args = new AutomationPropertyChangedEventArgs( property, null, wrappedObj); this._propChangeHandler(AutomationElement.Wrap(sender), args); }
void UIAutomationClient.IUIAutomationEventHandler.HandleAutomationEvent( UIAutomationClient.IUIAutomationElement sender, int eventId) { AutomationEventArgs args; if (eventId != WindowPatternIdentifiers.WindowClosedEvent.Id) { args = new AutomationEventArgs(AutomationEvent.LookupById(eventId)); } else { args = new WindowClosedEventArgs((int[])sender.GetRuntimeId()); } _basicHandler(AutomationElement.Wrap(sender), args); }
public static AutomationElement FromHandle(IntPtr hwnd) { Utility.ValidateArgument(hwnd != IntPtr.Zero, "Hwnd cannot be null"); try { UIAutomationClient.IUIAutomationElement element = Automation.Factory.ElementFromHandleBuildCache(hwnd, CacheRequest.CurrentNativeCacheRequest); return(AutomationElement.Wrap(element)); } catch (System.Runtime.InteropServices.COMException e) { Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; } } }
public static AutomationElement FromPoint(Point pt) { try { UIAutomationClient.IUIAutomationElement element = Automation.Factory.ElementFromPointBuildCache( Utility.PointManagedToNative(pt), CacheRequest.CurrentNativeCacheRequest); return(AutomationElement.Wrap(element)); } catch (System.Runtime.InteropServices.COMException e) { Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; } } }
public AutomationElement FindFirst(TreeScope scope, Condition condition) { Utility.ValidateArgumentNonNull(condition, "condition"); try { UIAutomationClient.IUIAutomationElement elem = this._obj.FindFirstBuildCache( (UIAutomationClient.TreeScope)scope, condition.NativeCondition, CacheRequest.CurrentNativeCacheRequest); return(AutomationElement.Wrap(elem)); } catch (System.Runtime.InteropServices.COMException e) { Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; } } }
internal AutomationElement(UIAutomationClient.IUIAutomationElement obj) { Debug.Assert(obj != null); this._obj = obj; }
void UIAutomationClient.IUIAutomationStructureChangedEventHandler.HandleStructureChangedEvent(UIAutomationClient.IUIAutomationElement sender, UIAutomationClient.StructureChangeType changeType, Array runtimeId) { StructureChangedEventArgs args = new StructureChangedEventArgs( (StructureChangeType)changeType, (int[])runtimeId); this._structureChangeHandler(AutomationElement.Wrap(sender), args); }
internal static AutomationElement Wrap(UIAutomationClient.IUIAutomationElement obj) { return((obj == null) ? null : new AutomationElement(obj)); }