Windows 7 32位中拦截并忽略键盘事件

发布于 2024-08-25 22:04:05 字数 490 浏览 9 评论 0原文

我的硬件有问题,时不时地发送“keydown”,然后发送“keyup”事件:

keydown:无 LButton,OemClear 255

keyup:无 LButton,OemClear 255

keyup:无 LButton,OemClear 255

keyup:无 LButton, OemC​​lear 255

在 Windows 中,它是这样的,每 1 或 2 秒一次,永远。

一般来说,它不会影响大多数应用程序,因为该密钥不可打印。我认为这是一个特殊的功能键,就像媒体键之类的。它没有任何作用。

但是,在某些监听 keydown 和 keyup 的应用程序中,我会得到意想不到的行为。

问题:有没有办法在Windows中拦截这2个键盘事件(对于所有应用程序和Windows本身)并让操作系统忽略它们?

这对我来说非常重要,如果您能想到任何解决方案,我将永远感激不已。

My hardware has a problem, from time to time it's sending a "keydown" followed by a "keyup" event:

keydown: None LButton, OemClear 255

keyup: None LButton, OemClear 255

keydown: None LButton, OemClear 255

keyup: None LButton, OemClear 255

It goes like this, every 1 or 2 seconds, forever, in Windows.

In general it doesn't affect most of the applications, because this key is not printable. I think it's a special function key, like a media key or something. It doesn't do anything.

But, in some applications that LISTEN to keydown and keyup, I get unexpected behaviour.

Question: is there a way to intercept these 2 keyboard events in Windows (for all applications & for Windows itself) and make the OS ignore them?

This is really important to me, if you can think of any solution, I'd be forever thankful.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

埋葬我深情 2024-09-01 22:04:05

您可以编写一个使用 RegisterHotKey 的小型应用程序将该击键注册为系统范围的热键。然后 Windows 会将该击键转换为发送到应用程序窗口的 WM_HOTKEY 消息。

这将导致您的应用程序每秒运行一次一些代码,这并不是非常理想,但它可能比替代方案更好。

窗口句柄需要属于您的应用程序,但它不必是可见的或非常大。热键是全局的,所以这有点像在键盘和其他应用程序之间安装一个钩子。

You can write a small application that uses RegisterHotKey to register that keystroke as a System wide hotkey. Then Windows will turn that keystroke into a WM_HOTKEY message to your application window.

This will cause your app to run a bit of code once a second or so, which is not really ideal, but it's perhaps better than the alternative.

The window handle needs to belong to your application, but it doesn't have to be visible or very large. The hotkey is global, so it's a bit like installing a hook between the keyboard and other applications.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文