Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to build an application to read data from handheld barcode scanner but I want this to run in the background (minimized window).

How to make my application reads the data from scanner without interrupting the applications in the foreground or without the data from the scanner to be send to the active window as well?
Posted
Comments
Sergey Alexandrovich Kryukov 18-Jun-14 13:07pm    
Do you mean that you have a "keyboard wedge" scanner which acts like a keyboard and hence "typing" in the focus control of an active window?
—SA
vadim1234 19-Jun-14 6:44am    
Yes, this is the case. But I want my application to catch the data without interupt the active window.
Sergey Alexandrovich Kryukov 19-Jun-14 12:22pm    
Yes, this is the problem...
—SA

1 solution

That's not easy - not easy at all. There are a couple of problems: most scanners are configured to act as a keyboard, so the barcode data goes to the active form as if it was keyboard data, and that is very hard to divert. It may be possible to configure the scanner to send a prefix and suffix code which identifies the data as a barcode but to do that you need to talk to teh manufacturer as there is no standard way to do that which all makers use.

Once you have done that, you need to do the hard bit: global hooking. And you can't do that in .NET, so you have to interface with a native application (or process) to do that - which can leave your system unstable in my experience if anything fails. But there are a couple of good artciles on it here:
Processing Global Mouse and Keyboard Hooks in C#[^]
Global System Hooks in .NET[^]

Good luck - this is not a trivial task in any way, shape or form!
 
Share this answer
 
Comments
vadim1234 19-Jun-14 6:55am    
Thanks for your reply but you do scared me ;)
Do you find easier, to make the data from the scanner to be written in a text file without interrupting the active windows?
Then will very easy for me to work with the flat file data.

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