We help IT Professionals succeed at work.
Get Started

C# Best method for capturing keyboard wedge barcode scanner data

locdang asked
Last Modified: 2013-12-17
Hi everyone,

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.


Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE