Click to See Complete Forum and Search --> : Mesages from USB device


eugenyk
September 27th, 2005, 02:35 PM
I have to use USB barcode scanner which emulates keyboard input in our program. It sends exactly the same messages as keyboard and it looks like there is no way to distinguish who sends these messages - regular keyboard or USB device.
I am thinking is there any way to reassign window which receives messages to USB device only?
By default it sends all input to active window whci has keyboard focus..

Any help will be appreciated.

golanshahar
September 27th, 2005, 05:13 PM
well i can suggest you what you can check maybe it will help you.

if i were you i would have set a WH_KEYBOARD_LL hook function using the ::SetWindowsHookEx(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp) api ( of course ;) ) and i would let the usb device to send data and in the hook fucntion i would trace all params are recieved in the KBDLLHOOKSTRUCT (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookstructures/kbdllhookstruct.asp) sturcture for instance the flags parameter which says:

LLKHF_INJECTED Test the event-injected flag.

to see if the key was injected.
and then do the same thing with real keyboard keys ( with the same keys of course ) and try to look if in the hook you can tell where keys come from.

and if you will be able then its simple you will use that hook and you will know where keyboard event came from.

it worth a shot ( i think :D )

Cheers