Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am implementing Bar code Scanner in Windows Application using C#
In a window if cursor is somewhere after scanning code it has to put the scanned data in Required text Box but it puts data in where the focus exists please kindly help me

What I have tried:

For Focused text box it is working fine
Posted
Updated 2-Oct-18 1:44am

You will need to talk to the manufacturer of your scanner.

Most scanners are shipped set to emulate a keyboard - so when you scan the code, the barcode data is transferred as if it had been typed at the keyboard. And Windows does not keep any track of the source of keyboard data, if there are two or more keyboard devices (or keyboard emulating devices, Windows doesn't care) then the data is fed into the same keyboard queue in the order they are received by the system.
Which means that you cannot tell if any input came from the scanner or from a user typing, and so you can't direct it at any particular control.

However, most scanners can be configured to give specific "lead in" and "tail out" sequences that you can detect, and direct the data between them where you want.

But ... each manufacturer - and often each model - has a different way to configure it, so you will need to contact the manufacturer and find out how to set the sequences.
 
Share this answer
 
You can configure your barcode scanner to use "Carriage Return Line Feed". It's the same as if you enter the code manually using your keyboard and then press enter. Then you can create an event for keypress/keydown/textchanged and listen for "ENTER" key. Its been a long time since i developed a desktop application so i can't exactly recall what event to create..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900