Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IUIAutomation::RemoveAllEventHandlers hangs

I am developing an app in C++ that uses UIAutomation to receive notification of significant events related to user interaction. I have tried anevent handler by calling AddAutomationEventHandler to listened for window opened events, but I am having problems stopping the notification and cleaning up before exiting. If the user has launched certain applications, such as Firefox, the call to RemoveAutomationEventHandlerhangs. (Calling RemoveAllEventHandlers also hangs in this case.) Note that all calls to add or remove event handlers are done in the context of the same non-UI thread.

Note: I am seeing this behavior on Windows 7 and on Windows 8.

Any ideas on why this is happening or how to fix it? What makes the structure changed event different from all the others?

like image 392
Wayne Avatar asked Nov 26 '12 22:11

Wayne


1 Answers

Window open/close events are implemented via the kernel WinEvent handlers; the structure change events involve the client app. Does your non-ui thread pump messages? UI Automation needs to pump messages to get cross-process communications working.

like image 155
Eric Brown Avatar answered Oct 20 '22 19:10

Eric Brown