0

I am learning Windows UI Automation, I intent to Add Automation Event Handler on Start menu, But when i click the Start menu, nothing happened on Windows 10 .

I try the same application on Windows 7,It works Could anyone help me. Thanks.

    private static void EventHandler()
    {
        AutomationElement start = null;
        PropertyCondition conds = new PropertyCondition(AutomationElement.NameProperty, "Start");
        start = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, conds);
        if (start != null)
        {
            Automation.AddAutomationEventHandler(InvokePattern.InvokedEvent, start,
               TreeScope.Element, new AutomationEventHandler(OnStartInvoke));

        }

    }
LKX
  • 16
  • 1
  • 1
    have you compared the structure of the UI Automatiom Tree already? e.g. with inspect.exe. Maybe your FindFirst returns a different AutomationElement in win10 compared to win7. – Haphil Apr 23 '16 at 08:19
  • @Hansa Thanks InvokePattern startInvoke = (InvokePattern)start.GetCurrentPattern(InvokePattern.Pattern); startInvoke.Invoke(); //The start menu is invoked , So I think the FindFirst returns a correct AutomationElement – LKX Apr 24 '16 at 14:13

0 Answers0