Link to home
Start Free TrialLog in
Avatar of ICSAutomation
ICSAutomationFlag for Switzerland

asked on

USB Scanner on Windows.Forms

Hello
I need to add a Barcodescanner to my application. The scanner is connected over a USB and behaves like a second keyboard.

As soon as a barcode is scanned, I want to open a new dialog and enter the read string into a textbox. This should happen, independed on which control of my application the focus is at the moment of the scan. (I can add a control-char at the beginning of the scann)
What is an easy way to do this?

I still use .NET 1.1 on Win XP

Avatar of Ariful Ambia
Ariful Ambia
Flag of Bangladesh image

you need Processing Keyboard Hooking

http://www.codeproject.com/KB/cs/globalhook.aspx
HI,

The USB bar code scanner is act like keyboard so you can do for scanning
1: Make sure when you want to scan focus must be in textbox (when focus is in textbox then all the is  written like keyboard )
2: Last character of code string is Enter key so you can check  this char in any event Like KeyPress,KeyDown etc. where you can display dialog box.

Regards

Dani
Avatar of ICSAutomation

ASKER

@mcs0506
I don't have the focus on a specific control/textbox. When I detect a scan, I want to open a new form first and the put the scan-string into a certain textbox of this new form.
you can scan first on previous form in hidden textbox after scanning you can go to the next form by using textbox event and if you any public string type variable in 2nd form then assign barcode string to that string variable before showing the 2nd form then in 2nd form you have barcode to use.

Regards

Dani
Or 0ne more option is there


Create a button Like Scan on First form when Scan button is clicked then show the 2nd form and onload set focus to that text box where you want and then perform acual scanning through barcode scanner.



Dani

@mcs0506
I'm looking for a solution where the scan creates an Event. I don't want to press a button first or want to be in a cetain control.

In every moment when a scan is done (doesn't matter what I'm doing in my application) the scecond form should open and the scan has to be read.
use my first comments

you can add textbox on 1st form as hidden textbox, make focus on that textbox after scanning you can go to the next form by using textbox event and if you any public string type variable in 2nd form then assign barcode string to that string variable before showing the 2nd form then in 2nd form you have barcode to use.
ASKER CERTIFIED SOLUTION
Avatar of Ariful Ambia
Ariful Ambia
Flag of Bangladesh image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial