Click here to Skip to main content
15,901,001 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My goal is to capture a barcode scan to see if the string contains a set value and then the ID. Our workstations utilize multiple interfaces and the proper interface to capture the scan is not always focused. I was thinking of having a background app to watch for a paticular string and then run a query.

If you know of a better app to use then a keystroke app, please advise.

Thanks in advance.
Posted
Comments
Sergey Alexandrovich Kryukov 24-Jul-11 0:50am    
How barcode is related to keyboard focus and events? What do you mean by "scan is not always focused"? Only controls can be focused or not. Why do you need keystroke info for barcode reading?
--SA
Keith Barrow 25-Jul-11 16:31pm    
Please see my extended solution, answering your question. As kschuler said, you should either comment on an answer or use the "Improve Question" button as there is a notification system in place for these. Answering your own question only notifies you !

If I understand you correctly, the thing to do is to raise an event, passing the barcode data when a scan is made. The GUI should react to the event by showing the relevant UI you want.
The scanner "listener" might need to run on a separate thread (to avoid blocking the UI), not its own application. That said, you might not need a thread if the Scanner API has an event you can hook in to.

[Edit]
The method of showing the window you need is dependant on what you want to do and how the window is "hidden", if your form is already open this might help, in the form's eventhandler for the scanned event
C#
TopMost = true;
Focus();
BringToFront();


One final thing, services are meant to be for long running processes, they don't [can't!] have UIs. Getting the inter-process communications (remoting) is relatively messy, and probably not needed. I suggest you make your UI app a syst tray one (For guidance see this website[^]). This way you start your app, it minimises itself into the system tray and when the scanner raises the "CodeRead" event you can unminise the UI and it should have focus (if not the code above should sort this). Once the user is done, the app can be re-minimised neatly into the systray.
 
Share this answer
 
v2
Comments
Kschuler 25-Jul-11 14:01pm    
Ron posted a question to you but did so in an answer instead of a comment. Here is what he wrote:
Kieth, you are correct. Do you have any advice or a direction I can go on of how to force the GUI to be focused? I know VB.net.
A windows service would be nice but I have been unsuccessful in making one work.

Thanks in advance.
Keith Barrow 25-Jul-11 14:34pm    
Thanks for the heads up.
Kieth, you are correct. Do you have any advice or a direction I can go on of how to force the GUI to be focused? I know VB.net.
A windows service would be nice but I have been unsuccessful in making one work.

Thanks in advance.
 
Share this answer
 
Comments
Kschuler 25-Jul-11 14:01pm    
Keith will not get notified that you have posted another answer to your own question. In the future, you could click Add Comment under his solution to ask him a question. I copied your question and pasted it to him that way.

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