I am writing a c# app that uses both user input and data retrieved from a keyboard wedge barcode scanner. Basically I have the application working at the moment by having the scanner scan into a textbox and detecting a carriage return as the barcode data terminator.
My problem is this application is run on a machine that has no keyboard / mouse only a number pad and a scanner. If (for whatever reason) the application loses focus to something else the barcode scanner does not work as the text box is no longer focused. Whilst we 'could' have a mouse also attached it would defeat our goal of minimal attached devices and increases the duties of the operating staff (I know clicking in a textbox isn’t a huge bit of labour but I am sure you all know that the customer / end user will complain about every 'unnecessary' mouse click they have to perform. We're also perfectionists :D)
A couple ideas I have had are:
Constantly evaluating and setting the application as the focused application
Using a low level keyboard hook
My problem with the auto focus method is that it may interfere with things like the task manager launching and also feels like more of a 'hack' than a solution and with the keyboard hook having the scanner hook play up with user data on the numerical keypad.
I am very interested to hear how others have combated this issue.