Ejemplo n.º 1
0
        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
                );
        }
Ejemplo n.º 2
0
        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 { }
                }
            });
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        /// <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);
Ejemplo n.º 6
0
        /// <inheritdoc />
        public override void UnregisterAutomationEventHandler(AutomationEventHandlerBase eventHandler)
        {
            var frameworkEventHandler = (UIA2AutomationEventHandler)eventHandler;

            UIA.Automation.RemoveAutomationEventHandler(UIA.AutomationEvent.LookupById(frameworkEventHandler.Event.Id), NativeElement, frameworkEventHandler.EventHandler);
        }