开发者

Can I use Global Hooks and Raw Input at the same time?

开发者 https://www.devze.com 2023-02-24 12:31 出处:网络
I tried using Global Hooks using SetWindowsHookEx to get all the the keystrokes. 开发者_如何转开发Problem is i cant use Global Hooks and Raw Input at the same time.

I tried using Global Hooks using SetWindowsHookEx to get all the the keystrokes.

开发者_如何转开发Problem is i cant use Global Hooks and Raw Input at the same time.

I'm thinking there must be some issue here because the Global Hooks automatically gets disabled after I enable Raw Inputs.


Who told you that they needed to be used together? If your application is registered to handle raw input, there's absolutely no reason to install a global hook. The whole point of the raw input model is for an application to receive notification of and process raw input from any HID connected to the computer.

Rather, you listen for the WM_INPUT message, which is sent to the application's message queue for any HID that you've registered by calling the RegisterRawInputDevices function. Upon receipt of this message, your application should call the GetRawInputData function using the RAWINPUT handle contained in the lParam parameter of the WM_INPUT message. Sample code is available here.

Alternatively, you can do a buffered read of the raw data. This is more useful for devices that generate large amounts of input at a time. With this approach, you call the GetRawInputBuffer function, which returns an array of RAWINPUT structures. Again, sample code is available here.

Topical reading on the Raw Input functions is here on MSDN.


You don't need a hook for the raw input which already checked by the LRESULT WindowProcedure callback. You just need to get the information back if a device was used like a mouse_pos, mouse_click (and its number of clicks which you can determine by a counter), key_input, etc...

0

精彩评论

暂无评论...
验证码 换一张
取 消