protected void RegisterAwaitersEvents(AutomationElement root) { AwaiterParent = root; AwaiterStructureChangedHandler = root.RegisterStructureChangedEvent( TreeScope.Children, OnStructureChanged ); AwaiterWindowOpenedHandler = RegisterAutomationEventManual( root, UIAuto.EventLibrary.Window.WindowOpenedEvent, TreeScope.Children | TreeScope.Element, IsSMProcess, Awaiter_OnWindowOpened ); AwaiterWindowClosedHandler = RegisterAutomationEventManual( root, UIAuto.EventLibrary.Window.WindowClosedEvent, TreeScope.Children | TreeScope.Element, IsSMProcess, Awaiter_OnWindowClosed ); }
public WindowHandle(int pid, AutomationElement win, List <WindowHandle> list) { Pid = pid; Win = win; Handle = win.Properties.NativeWindowHandle.Value.ToInt32(); AutomationEventHandlerBase closeEvent = null; closeEvent = win.RegisterAutomationEvent(new FlaUI.Core.Identifiers.EventId(WinCloseEventId, "WindowClosedEvent"), TreeScope.Element, (removed, evType) => { if (!removed.IsAvailable) { list.Remove(this); Win = null; try { closeEvent.Dispose(); } catch { } } }); }
protected void UnregisterAwaitersEvents() { if (AwaiterStructureChangedHandler != null) { AwaiterParent.FrameworkAutomationElement.UnregisterStructureChangedEventHandler(AwaiterStructureChangedHandler); } if (AwaiterWindowOpenedHandler != null) { UnregisterAutomationEvent(AwaiterParent, AwaiterWindowOpenedHandler); } if (AwaiterWindowClosedHandler != null) { UnregisterAutomationEvent(AwaiterParent, AwaiterWindowClosedHandler); } AwaiterParent = null; AwaiterStructureChangedHandler = null; AwaiterWindowOpenedHandler = null; AwaiterWindowClosedHandler = null; }
/// <inheritdoc /> public override void UnregisterAutomationEventHandler(AutomationEventHandlerBase eventHandler) { var frameworkEventHandler = (UIA3AutomationEventHandler)eventHandler; Automation.NativeAutomation.RemoveAutomationEventHandler(frameworkEventHandler.Event.Id, NativeElement, frameworkEventHandler); }
/// <summary> /// Unregisters the given automation event handler. /// </summary> public abstract void UnregisterAutomationEventHandler(AutomationEventHandlerBase eventHandler);
/// <inheritdoc /> public override void UnregisterAutomationEventHandler(AutomationEventHandlerBase eventHandler) { var frameworkEventHandler = (UIA2AutomationEventHandler)eventHandler; UIA.Automation.RemoveAutomationEventHandler(UIA.AutomationEvent.LookupById(frameworkEventHandler.Event.Id), NativeElement, frameworkEventHandler.EventHandler); }