原始输入是替代键盘挂钩吗?
简单的问题——
我正在阅读有关键盘挂钩的内容,有人建议使用原始输入来执行此操作,但我还没有找到任何示例。 例如,我在
RAWINPUTDEVICE rid[1];
rid[0].usUsagePage = 0x01;
rid[0].usUsage = 0x06;
rid[0].hwndTarget = hWnd;
rid[0].dwFlags = 0;
RegisterRawInputDevices(rid, 1, sizeof(rid[0]));
应用程序自己的窗口中使用 And catchsign WM_INPUT 很好,但不在应用程序之外。这可以在应用程序之外实现吗?还是必须使用 WH_KEYBOARD 或 WH_KEYBOARD_LL? MSDN 没有明确说明原始输入是否可以在全球范围内进行。
编辑:我了解 Hooks,但我想知道你是否也可以使用原始输入来做到这一点!
干杯
Quick question --
I was reading about keyboard hooks and one suggested using Raw Input to do this, yet I havn't found any example of it.
For example I am using
RAWINPUTDEVICE rid[1];
rid[0].usUsagePage = 0x01;
rid[0].usUsage = 0x06;
rid[0].hwndTarget = hWnd;
rid[0].dwFlags = 0;
RegisterRawInputDevices(rid, 1, sizeof(rid[0]));
And catchign WM_INPUT fine in the applications own window, but not outside the application. Is this possible outside the application or do you have to use WH_KEYBOARD or WH_KEYBOARD_LL? MSDN didn't make it clear if Raw Input could be made globally.
EDIT: I know about Hooks but I want to know if you can do it with Raw input too!
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看该内容的 MSDN 文档,有一个名为 < code>RIDEV_INPUTSINK 描述为:“如果设置,即使调用者不在前台,也可以使调用者接收输入。”
我自己并没有搞乱这一点,但听起来它对于从应用程序窗口之外获取输入可能很有用。
Looking at the MSDN documentation for that stuff, there is a flag called
RIDEV_INPUTSINK
which is described as: "If set, this enables the caller to receive the input even when the caller is not in the foreground."I haven't messed with that myself, but it sounds like it could be useful for getting input from beyond the application's window.
这就是我初始化 RAW INPUT 以全局拦截鼠标和键盘事件的方式。与钩子相比,最大的优点是不需要 DLL。
您可以使用
WM_INPUT
处理窗口过程中的原始输入事件。有关详细信息:原始输入< /a>This is how I initialize
RAW INPUT
to globally intercept mouse and keyboard events. The great advantage compared to hooks is you don't need a DLL.You treats the raw input events in the window procedure with
WM_INPUT
. For further informations : RAW INPUTWindows 挂钩是一种可以在事件到达应用程序之前拦截事件的机制。过滤器函数(接收事件的函数)根据事件类型进行分类。如果想要附加到 Windows 挂钩,则必须使用
SetWindowsHookEx
安装过滤器功能。我不得不提一下,全局钩子必须位于单独的 dll 文件中。您可以在 MSDN。A Windows hook is mechanism that one can use to intercept events before they reach an application. Filter functions (functions that receive events) are classified according to the event type. If one wants to attach to a Windows hook, the filter function has to be installed using
SetWindowsHookEx
. I have to mention that global hooks must be in a separate dll file. You can read more about hooks in MSDN.不确定原始输入,但对于键盘钩子,一般来说,您需要将其设为 dll 并在系统中注册,以便每个进程都会加载它。备注中的一些详细信息此处
not sure exactly about raw input, but for keyboard hook in general you need to make it a dll and register in system so it will be loaded by every process. some details here in remarks