为什么SetWinEventHook有时会停止/暂停监听事件?

发布于 2024-10-20 13:38:32 字数 1157 浏览 1 评论 0原文

启动 WinEventHook 似乎工作不可靠。 什么会导致事件挂钩有时仅监视事件(或运行已识别的事件过程函数)?

IE。在 IE8 BHO 中,

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

我经常收到事件,但是在最近的构建之后,它不起作用,除非我还运行 MS“可访问事件观察程序”,停止和启动事件观察程序也会停止和启动我的事件进程被召唤。

我没有在最近的版本中更改 SetWinEventHook,所以我不认为这是原因。 所有其他线程/消息泵送操作都按预期进行,因此我不认为在线程上泵送消息失败是原因。

使用 http://www.quirksmode.org/dom/events/ 测试获取重新排序事件tests/DOMtree.html 并添加/删除测试元素。

编辑:
经过进一步测试,变化可能是我停止运行 “可访问的事件观察器” 而不是构建。

没有“可访问事件观察器”的事件挂钩捕获的事件范围似乎是 [first, last) 或 eventMin 到 eventMax-1,这与文档 SetWinEventHook 启动“可访问事件观察程序”时,范围会发生变化并且显示为 [first,last],因此使用 EVENT_OBJECT_FOCUS 的 eventMax 似乎获得了看到 EVENT_OBJECT_REORDER 的预期结果。

我在这里遗漏了什么,还是文档只是错了,事件观察者也在做一些事情?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文