Example #1
0
        public void InvokedEventTest()
        {
            AutomationEvent automationEvent = InvokePatternIdentifiers.InvokedEvent;

            Assert.IsNotNull(automationEvent, "Property field must not be null");
            Assert.AreEqual(20009, automationEvent.Id, "Id");
            Assert.AreEqual("InvokePatternIdentifiers.InvokedEvent", automationEvent.ProgrammaticName, "ProgrammaticName");
            Assert.AreEqual(automationEvent, AutomationEvent.LookupById(automationEvent.Id), "LookupById");
        }
        public void WindowOpenedEventTest()
        {
            AutomationEvent automationEvent = WindowPatternIdentifiers.WindowOpenedEvent;

            Assert.IsNotNull(automationEvent, "Property field must not be null");
            Assert.AreEqual(20016, automationEvent.Id, "Id");
            Assert.AreEqual("WindowPatternIdentifiers.WindowOpenedProperty", automationEvent.ProgrammaticName, "ProgrammaticName");
            Assert.AreEqual(automationEvent, AutomationEvent.LookupById(automationEvent.Id), "LookupById");
        }
        public void ElementSelectedEventTest()
        {
            AutomationEvent automationEvent = SelectionItemPatternIdentifiers.ElementSelectedEvent;

            Assert.IsNotNull(automationEvent, "Property field must not be null");
            Assert.AreEqual(20012, automationEvent.Id, "Id");
            Assert.AreEqual("SelectionItemPatternIdentifiers.ElementSelectedEvent", automationEvent.ProgrammaticName, "ProgrammaticName");
            Assert.AreEqual(automationEvent, AutomationEvent.LookupById(automationEvent.Id), "LookupById");
        }
        public void InvalidatedEventTest()
        {
            AutomationEvent automationEvent = SelectionPatternIdentifiers.InvalidatedEvent;

            Assert.IsNotNull(automationEvent, "Event field must not be null");
            Assert.AreEqual(20013, automationEvent.Id, "Id");
            Assert.AreEqual("SelectionPatternIdentifiers.InvalidatedEvent", automationEvent.ProgrammaticName, "ProgrammaticName");
            Assert.AreEqual(automationEvent, AutomationEvent.LookupById(automationEvent.Id), "LookupById");
        }
Example #5
0
        public void TextSelectionChangedEventTest()
        {
            AutomationEvent automationEvent = TextPatternIdentifiers.TextSelectionChangedEvent;

            Assert.IsNotNull(automationEvent, "Property field must not be null");
            Assert.AreEqual(20014, automationEvent.Id, "Id");
            Assert.AreEqual("TextPatternIdentifiers.TextSelectionChangedEvent", automationEvent.ProgrammaticName, "ProgrammaticName");
            Assert.AreEqual(automationEvent, AutomationEvent.LookupById(automationEvent.Id), "LookupById");
        }
Example #6
0
        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);
        }
Example #7
0
        /// <summary>
        /// Function for manually testing tree trasversing.
        /// </summary>
        /// <param name="relPath"></param>
        public static void manualTreeTrasversing(List <Either <STreeNode, CTreeNode> > relPath)
        {
            AutomationElement currNode;

            currNode = TreeWalker.ContentViewWalker.GetFirstChild(AutomationElement.RootElement);

            while (true)
            {
                string  action  = Console.ReadLine();
                MAction pAction = parseAction(action);
                Option <AutomationElement> actionRes;

                if (pAction != MAction.notSupported)
                {
                    if (pAction != MAction.attach)
                    {
                        actionRes = execMove(pAction, currNode);
                        actionRes.Match(
                            Some: (node) => currNode = node
                            , None: () => { }
                            );
                    }
                    else
                    {
                        var res = attachHandler(relPath
                                                , AutomationEvent.LookupById(20003)
                                                , currNode
                                                , TreeScope.Children
                                                , (sender, args) => { Console.WriteLine("Something changed"); });
                        if (res == None)
                        {
                            Console.WriteLine("Attached correctly");
                        }
                    }
                }
                else if (action == "b")
                {
                    Console.WriteLine("Closing...");
                    break;
                }
                else
                {
                    Console.WriteLine("Not supported move: `" + pAction + "`");
                }
                Console.WriteLine("Actual Node: " + currNode.Current.Name);
            }
        }
Example #8
0
        // Advises event sinks that an event has been removed.
        void IRawElementProviderAdviseEvents.AdviseEventRemoved(int eventIdAsInt, int[] propertiesAsInts)
        {
            AutomationEvent eventId = AutomationEvent.LookupById(eventIdAsInt);

            AutomationProperty [] properties = null;
            if (propertiesAsInts != null)
            {
                properties = new AutomationProperty[propertiesAsInts.Length];
                for (int i = 0; i < propertiesAsInts.Length; i++)
                {
                    properties[i] = AutomationProperty.LookupById(propertiesAsInts[i]);
                }
            }

            //ProxyHwnd.AdviseEventRemoved
            AdviseEventRemoved(eventId, properties);
        }
Example #9
0
 private void EnsureAutomationEventsSetUp(DCI.IApplication app, string busName)
 {
     if (!automationEventBusNames.Contains(busName))
     {
         automationEventBusNames.Add(busName);
         app.AutomationEvent += delegate(int hId, int evtId, string providerPath) {
             var handler = eventHandlerManager.GetAutomationEventHandlerById(hId);
             if (handler != null)
             {
                 UiaDbusElement    elem = GetOrCreateElement(busName, providerPath);
                 AutomationElement ae   = SourceManager.GetOrCreateAutomationElement(elem);
                 var args = new AutomationEventArgs(AutomationEvent.LookupById(evtId));
                 handler(ae, args);
             }
         };
     }
 }
        public void LayoutInvalidatedEventTest()
        {
            AutomationEvent myLayoutInvalidatedEvent =
                AutomationElementIdentifiers.LayoutInvalidatedEvent;

            Assert.IsNotNull(
                myLayoutInvalidatedEvent,
                "Field must not be null.");
            Assert.AreEqual(
                20008,
                myLayoutInvalidatedEvent.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.LayoutInvalidatedEvent",
                myLayoutInvalidatedEvent.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myLayoutInvalidatedEvent,
                AutomationEvent.LookupById(myLayoutInvalidatedEvent.Id),
                "LookupById");
        }
        public void AsyncContentLoadedEventTest()
        {
            AutomationEvent myAsyncContentLoadedEvent =
                AutomationElementIdentifiers.AsyncContentLoadedEvent;

            Assert.IsNotNull(
                myAsyncContentLoadedEvent,
                "Field must not be null.");
            Assert.AreEqual(
                20006,
                myAsyncContentLoadedEvent.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.AsyncContentLoadedEvent",
                myAsyncContentLoadedEvent.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myAsyncContentLoadedEvent,
                AutomationEvent.LookupById(myAsyncContentLoadedEvent.Id),
                "LookupById");
        }
        public void StructureChangedEventTest()
        {
            AutomationEvent myStructureChangedEvent =
                AutomationElementIdentifiers.StructureChangedEvent;

            Assert.IsNotNull(
                myStructureChangedEvent,
                "Field must not be null.");
            Assert.AreEqual(
                20002,
                myStructureChangedEvent.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.StructureChangedEvent",
                myStructureChangedEvent.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myStructureChangedEvent,
                AutomationEvent.LookupById(myStructureChangedEvent.Id),
                "LookupById");
        }
        public void ToolTipClosedEventTest()
        {
            AutomationEvent myToolTipClosedEvent =
                AutomationElementIdentifiers.ToolTipClosedEvent;

            Assert.IsNotNull(
                myToolTipClosedEvent,
                "Field must not be null.");
            Assert.AreEqual(
                20001,
                myToolTipClosedEvent.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.ToolTipClosedEvent",
                myToolTipClosedEvent.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myToolTipClosedEvent,
                AutomationEvent.LookupById(myToolTipClosedEvent.Id),
                "LookupById");
        }
Example #14
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Query to ensure we have a definition for the LiveRegionChanged event.
            _liveRegionsSupported = AutomationEvent.LookupById(UIA_LiveRegionChangedEventId) != null;

            if (_liveRegionsSupported)
            {
                // Query and store the LiveSettingProperty to later apply to our TextBlock.
                if (_liveSettingProperty == null)
                {
                    _liveSettingProperty = typeof(AutomationProperties).GetField("LiveSettingProperty", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null) as DependencyProperty;
                }

                if (_liveSettingProperty != null)
                {
                    // Apply "Assertive" to our TextBlock.
                    // See: https://docs.microsoft.com/en-us/dotnet/api/system.windows.automation.automationlivesetting?view=netframework-4.8
                    Updater.SetValue(_liveSettingProperty, Enum.Parse(_liveSettingProperty.PropertyType, "2"));
                }
            }
        }