I'm making a "driver" for a barcode scanner.
This particular scanner is basically a USB keyboard that generates keystrokes whenever something is scanned.
I want to find a way to distinguish these keystrokes from those keystrokes a proper keyboard sends. Unfortunately the only difference is that scanner generates keystrokes really fast, a bunch of keyups and keydowns in a fraction of a second.
The way I see it is I have to set up a global keyboard hook that intercepts all input, stores it somehow, waits for a tiny bit then either sends those keystrokes further down the hook chain or assumes they are something that scanner generated and handles them appropriately.
However, having no prior experience with hooks, I am not sure about the right way to do it. Can I just invoke CallNextHookEx()
in some method other than KeyboardProc()
in some other thread to pass the delayed keystroke event? Or should I rather generate a new WM_KEYPRESS
message manually? Maybe there is an altogether better way to go about this thing?
Thanks.