Reputation: 505
I have 2 USB HID keyboards. They have different VID and PID's.
Now I want, in VB.NET, set up a system global hook when my application starts, so it only "Catch" events from one of the keyboards.
Eg, if I open notepad, and enter things on Keyboard1, with VID 04F3 and PID 0103, I want it to show up in notepad as normal, and my application should ignore the inputs. Best for performance is that my application does not even need to pass on the events.
But if I enter things on Keyboard2, with VID 13BA and PID 0018, I want the inputs from that keyboard to be "sucked up" by my application running as a service. Nothing should show up in notepad. My application will instead react based on the input from Keyboard2.
Any ideas on how this can be accomplished?
Upvotes: 0
Views: 2200
Reputation: 69
You usually can hook the keyboard events by injecting a filter driver upon Kbdclass driver as described in the following link.
http://msdn.microsoft.com/en-us/library/windows/hardware/jj128406(v=vs.85).aspx
The report format is described as KEYBOARD_INPUT_DATA.
If you want only to hook certain USB keyboard, you have to inject the filter driver between HIDclass and HID transport(hidusb.sys). HID transport driver reports the keyboard event in the form of HID input report and it varies among the indivisual keyboard. So it's theoritically possible to hook/block the keyboard inputs by the filter driver which located upon hidusb.sys.
However, you have to know or do reverse-engineering of the format of input reports that the keyboard you're interested reports on every key inputs.
Upvotes: 1