Why does SetWinEventHook sometimes stop/pause monitoring events?

785 views Asked by At

Starting up a WinEventHook doesn't seem to be working reliably. What would cause an event hook to only monitor events (or run the identified event proc function) sometimes?

ie. inside an IE8 BHO

HWINEVENTHOOK eHook = ::SetWinEventHook(EVENT_OBJECT_SHOW, EVENT_OBJECT_REORDER
 , 0
 , MSAALib_WinEventProc
 , GetCurrentProcessId(), GetCurrentThreadId()
 , WINEVENT_OUTOFCONTEXT );

I've been getting events quite regularly, but after a recent build it doesn't work except when I'm also running MS "Accessible event watcher", stopping and starting the event watcher also stops and starts my event proc being called.

I haven't changed the SetWinEventHook in any recent build so I do not believe this is the cause. All the other thread/message pumping actions are taking place as expected so I do not believe failure to pump messages on the thread is the cause.

Testing getting reorder events using http://www.quirksmode.org/dom/events/tests/DOMtree.html and adding/removing test elements.

Edit:
Upon further testing it appears the change may have been that I stopped running the "Accessible event watcher" and not the build.

The range of events captured by the event hook without the "Accessible event watcher" appears to be [first, last) or eventMin to eventMax-1 which is not as per the doc SetWinEventHook when starting the "Accessible event watcher" the range changes and appears to be [first,last] so using an eventMax of EVENT_OBJECT_FOCUS seems to get the desired result of seeing EVENT_OBJECT_REORDER.

Is there something I'm missing here, or is the doc just wrong and the event watcher is doing something aswell?

0

There are 0 answers