Windows 7 32位中拦截并忽略键盘事件
我的硬件有问题,时不时地发送“keydown”,然后发送“keyup”事件:
keydown:无 LButton,OemClear 255
keyup:无 LButton,OemClear 255
keyup:无 LButton,OemClear 255
keyup:无 LButton, OemClear 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以编写一个使用 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.