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_INPUTmessage, which is sent to the application’s message queue for any HID that you’ve registered by calling theRegisterRawInputDevicesfunction. Upon receipt of this message, your application should call theGetRawInputDatafunction using theRAWINPUThandle contained in thelParamparameter of theWM_INPUTmessage. 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
GetRawInputBufferfunction, which returns an array ofRAWINPUTstructures. Again, sample code is available here.Topical reading on the Raw Input functions is here on MSDN.