views:

139

answers:

1

Following on from the question asked by Mykroft

Best way to handle input from a keyboard “wedge”

http://stackoverflow.com/questions/42437/best-way-to-handle-input-from-a-keyboard-wedge.

I need to write a class that intercepts key strokes, if the input is determined to be from the keyboard wedge (as described in the above post) the data will be directed to POS classes to handle, otherwise they keystrokes must be passed on to be handled in windows in the normal manner. This raises two questions

  1. How can I intercept key strokes when not in a WinForm.

  2. How can I pass on the keypresses to windows.

Thanks JDibble

+1  A: 

You'll need to P/Invoke SetWindowsHookEx(). The only hook that will work in a .NET app is WH_KEYBOARD_LL. You should get loads of hits on example code when you Google these keywords.

Hans Passant
Thanks for the direction.
JDibble
The P/Invoke SetWindowsHookEx() approach allows me to collect key strokes perfectly, and pass them on to my classes. Just ned to work on re-sending them to windows if they are determined not to be from the keyboard wedge device.
JDibble