UI Automation - WinForms Button not invoking event even after subscribing using "AddAutomationEventHandler" InvokePattern.InvokedEvent

  • Thread starter Thread starter Shyam V
  • Start date Start date
S

Shyam V

Guest
Here is the code



// Get element

PropertyCondition sendEmailButtonCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, "buttonCalculate");
AutomationElement sendButton = dotNetCalculator.FindFirst(TreeScope.Descendants,
new PropertyCondition(AutomationElement.AutomationIdProperty, "buttonCalculate"));


// Subscribe


if (elementButton != null)
{
Automation.AddAutomationEventHandler(InvokePattern.InvokedEvent,
elementButton, TreeScope.Element,
UIAeventHandler = newAutomationEventHandler(handler));
}

// Handler

private void handler(object sender, AutomationEventArgs e)
{
MessageBox.Show("Invoke event occured");
}



Why not the handler is not triggering? It works on system "Calculator" which is developed in WPF.

Thanks & Regards


Shyam




Continue reading...
 
Back
Top