简体   繁体   English

如何捕获特殊的关键事件?

[英]How to capture special key events?

On my laptop I have several special keys, not found on a standard keyboard, like changing performance profiles. 在笔记本电脑上,我有几个特殊的键,如更改性能配置文件,这些键在标准键盘上找不到。 The vendor supplied a software that handles this key. 供应商提供了处理该密钥的软件。 Is there a way to catch this key event from a custom program? 有没有办法从自定义程序中捕获此关键事件? As far as I know Windows internally works with messages. 据我所知,Windows内部可处理消息。 How could I listen to all keyboard related messages and log the id of the key so I could know later which key id should handle? 如何收听所有与键盘相关的消息并记录键的ID,以便以后知道应该处理哪个键ID?

I think Register Hotkey may be what you are looking for, you can handle normal keyboard interaction as normal and use Register Hotkey to handle the hotkeys. 我认为您可能正在寻找“ 注册热键 ”,您可以像平常一样处理正常的键盘交互,并使用“注册热键”来处理热键。

You may also want to take a look at http://www.autohotkey.com/ which provides a pre-made version of what you are looking for. 您可能还想看看http://www.autohotkey.com/ ,它提供了您所寻找内容的预制版本。 (may not suit your needs though, so not sure about this) (虽然可能无法满足您的需求,所以对此不太确定)

Another approach would be to use wh_keyboard hook (with an example located here on how to utilise this as a DLL). 另一种方法是使用wh_keyboard钩子( 此处有一个示例说明如何将其用作DLL)。 And an overview of Windows Hooks here . 与windows钩子的概述这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM