May 20, 2021

Creating win32 AutomationEventHandler with com object in c#

Creating win32 AutomationEventHandler with com object in c#

Hi! I'm using the com object of win32 IUIAutomation and I'm trying to listen to an element and see if it's being invoked, but for some reason, I can't create an EventHandler. Here is the code:

private void ElementSubscribeCheck()

{

TreeScope scope = new TreeScope();

IUIAutomationEventHandler handler = new IUIAutomationEventHandler();

automation.AddAutomationEventHandler(20009, _element, scope, null, handler);

}

private void Method(object sender, int eventId) { }

It says that I can't do IUIAutomationEventHandler handler = new IUIAutomationEventHandler();

So how do I do it?

submitted by /u/Omikor
[link] [comments]