dcsimg
Results 1 to 7 of 7

Thread: USB Barcode Scanner Reading

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    10

    USB Barcode Scanner Reading

    Hi

    We are using USB barcode scanner to scan material barcode labels. These labels are from our vendors.
    We does not have control over the label generation. We are using USB barcode scanner for scanning purpose. We want to capture USB barcode scanner output. Normally the scanner returns output in the place holder in which the cursor present.

    But we do not put writable text box for the cursor. Instead of write allowable text box we want to put locked or readonly text box in the screen and want to capture scanner value.
    How can we do?

    Assume that our barcode scanner does not support serial ports.

    Regards

    S. Muhilan

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: USB Barcode Scanner Reading

    To the best of my knowledge a barcode scanner would enter data into a field just like a keyboard. So if you disable keyboard input into the textbox, most likely the barcode scanner may not be able to work with it as well.

    Any specific reason you want to disable user entry into the barcode field? If the scanner broke down or if the label was unreadable by the scanner, the user could always enter the barcode manually. Just an idea.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: USB Barcode Scanner Reading

    Yes, USB Barcode Scanners behave EXACTLY like keyboards. Scanning a code is the same to a computer as if you typed it in on the keyboard. If you can't type it in with the keyboard then your scanner won't be able to put it in either.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: USB Barcode Scanner Reading

    I know nothing about bar-code scanners but here are a couple of ideas:

    1. Begging your pardon, Jenner, but is it possible that you could distinguish between a scanner and a keyboard by trapping the keydown and keypress events? I know you said KB and scanner were identical, but it occurred to me that keydown/keypress were not really applicable to a scanned input so might not be fired.

    2. Can you put a hidden textbox on your form into which the scanner puts its output. You would then programatically copy from this field to a read-only textbox that was visible to the user.
    This world is not my home. I'm just passing through.

  5. #5
    Member intellilogic's Avatar
    Join Date
    Oct 2010
    Location
    Tyson's Corner, VA
    Posts
    39

    Re: USB Barcode Scanner Reading

    Why don't you tell us more about exactly what scanner you are using? I am using a Symbol(Motorola) DS3478SF. I started by going to the website and downloading some sample software, my problem was my soft came out in VB6, after some searching, I decided it was easiest to leave that portion of the program in VB6 and used API to push it to my .Net app.

    Ok next you are going to have to reconfigure your scanner. You will need the programming barcodes for this. Scan: 'set defaults' and 'HID keyboard emulation' DO NOT scan anything that says 'line' feed. Else you will end up where you are now that it feeds in on whatever line you are on. Which is NOT what you are trying to do.

    Now here comes the tricky part. In order to get this into the app, you have to do these things (should be features in your sample code) in this order; though the order may seam illogical as it did/does to me: Open (Opening the decide name, mine is: STI_USBSCANNER) CLAIM, Device Enable. Make sure you have Decode data and Enable Data event ON. Else it won't do anything. I made this all into a function when my app loads:

    Code:
    Public Sub EnableBarcodeScanner()
        frmBCS.Show
        frmBCS.Visible = False
    
        frmBCS.btOpen_Click
        frmBCS.btClaim_Click
        frmBCS.btDevice_Click
        
        frmBCS.ckDecodeData.Value = 1
        frmBCS.Scanner1.DecodeData = True
        
        frmBCS.ChkAutoEventEnable.Value = 1
        frmBCS.Scanner1.DataEventEnabled = True
    End Sub
    Now you should get your SKU into the program, you should be able to take it from here. You may need some concatenation and adding dashes and such.

    My mangling / concatinating:
    Code:
    Private Sub txtConversion_Change()
        Dim strOrigional As String
        Dim strL As String
        Dim strR As String
    
            strOrigional = Left$(txtConversion.Text, 10)
            strL = Left$(strOrigional, 5)
            strR = Right$(strOrigional, 5)
            txtSku.Text = strL + "-" + strR
    End Sub
    Use many TextBox_Change() to keep pushing your SKU through, when I scan something, it makes it to it's destination instantly

    My end result looked like so:

  6. #6
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: USB Barcode Scanner Reading

    1. No, the scanner will still trigger KeyDown and KeyPress events. KeyDown happens when Microsoft Windows detects a key event. The scanner is literally sending key-presses to Windows.

    The heart of the problem is Windows can't distinguish between two keyboards hooked up to the same computer. Window's driver system pipes IO from all keyboard devices connected to the same buffer. The only way to separate them is to literally tell Windows "this is NOT a keyboard" and write a special driver for it along with a special programming API.

    2. No, this won't work either; but there is a solution that's similar. You can use a keyboard hook to intercept all keyboard input before they hit your program. Then, you can tell Windows whether the data is "handled" i.e. "Don't send this to the program's GUI" or not handled which will pass the inputs along to the GUI and make text appear in textboxes as normal. The tough part still becomes can you distinguish between data the scanner is reading and normal key-presses.

    In the application I did, I programmed my barcode scanner to prepend a "@" symbol before any codes (which were always 12 digits), so when the keyboard hook saw a "@" get input, it "handled" it and buffered the next 12 characters which it also "handled". If those next 12 took more than a half-second to be input, it released itself and pushed what it had to the program (because it was normal keyboard input, not from the scanner). If it got all 12 and they matched an order, it processed the data and any further input it released (until it received another @ that is).

    This is pretty much the only way to program a "dumb-scanner" if you don't want to select a field and have it fill it in as a keyboard input.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  7. #7
    New Member
    Join Date
    Nov 2010
    Posts
    1

    Re: USB Barcode Scanner Reading

    I think I would cheat.

    Make a hidden div with text input field and focus on the text input field. If you want you can make also a visible text input field for users to press in vain.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width