InvokePattern.Invoke() or simple click does not call InvokedEvent handler

  • Thread starter Thread starter folkwulf
  • Start date Start date
F

folkwulf

Guest
Hello to all!


I have next situation:

  1. Application A: WinForms application with one button;
  2. Application B: Console application with automation functionality;
  3. I set AutomationEventHandler with AutomationEvent InvokePattern.InvokedEvent and perform Automation.AddAutomationEventHandler;
  4. Application B do not catch invoke event of Application A when I perform InvokePattern.Invoke() or simple click on button of Application A.


Sample of code:


Automation.AddAutomationEventHandler(InvokePattern.InvokedEvent, uiControl, TreeScope.Element, new AutomationEventHandler(OnUIAutomationEventHandler));

Thread.Sleep(5000);

var invokePattern = uiControl.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
invokePattern.Invoke();


// Or here I make click.


Thread.Sleep(5000);

Automation.RemoveAutomationEventHandler(InvokePattern.InvokedEvent, uiControl, uiaEventHandler);


private static void OnUIAutomationEventHandler(object sender, AutomationEventArgs e)
{
Console.WriteLine("INVOKED!");
}



Additional information: if Application A is WPF then all work good that I am think problem is related to WinForms.



Please, help to understand what could be the problem.


Thanks in advance!

Continue reading...
 
Back
Top