Results 1 to 7 of 7

Thread: translate barcode scan for external program

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    translate barcode scan for external program

    this is a new one to me

    i want to detect a scanned barcode then return a translated string to an external program
    the barcode scanner is a usb hid, so works like a keyboard wedge
    it also has serial mode if i ever figure how to use it

    the barcodes are as received and completely out of my control, i am unable as yet to identify what type they are, from several different manufacturers

    i can see several options for this, but really looking for best solution, not to cause other issues on the computer

    i can see a simple 2 field database table to look up the product id from the scan, with UI to add new
    a keyboard hook should detect incoming scans, but how best to read the barcode string, then send the productid to external programs focused control

    anyone done any of this or have suggestions please
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: translate barcode scan for external program

    Normally when using a wedge mode scanner you would configure the scanner to send a suffix character after the barcode and use that as a trigger to process the data.

    For example I normally just configure the scanner to send a CR after the barcode. I would have a textbox on a form and setfocus to it. In the keypress event I add some code to check for a CR and when I get one process the data in the text box then clear the textbox to be ready for the next scan.

    I prefer serial over wedge mode but either will do the job. In serial mode you just use a MSComm control and the data will appear in the oncomm event. Again I would configure the scanner to send a CR after the data and the code would buffer up any incoming data until it sees the CR then process the data and repeat.

  3. #3
    Lively Member
    Join Date
    Apr 2015
    Posts
    120

    Re: translate barcode scan for external program

    Just a text box with focus . In the examble its txtBC.

    Code:
    Private Sub txtBC_KeyPress(KeyAscii As Integer)
    
    If KeyAscii = 13 Then
        txtBC.Text = StrOnlyNum(txtBC.Text) ' To remove CR etc
        '
        ' here seek BarCode table to find product's Code
        '
    End If
    
    End Sub

  4. #4
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,190

    Re: translate barcode scan for external program

    Quote Originally Posted by westconn1 View Post
    then send the productid to external programs focused control
    I agree with everything DataMiser wrote and that got you the first part of your question. I'm not clear on your exact need above though. You have a third-party program that you don't control that has a textbox for example that you need to fill with the Product ID?

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: translate barcode scan for external program

    You have a third-party program that you don't control that has a textbox for example that you need to fill with the Product ID?
    exactly that, if the scan was going to a program i was writing i doubt this post would exist, but i need my program to intercept the scan then push the productId to someother program, into the next empty row textbox, or send a heap of tabs (or down arrow) to move the focus to the next row

    a very few of the barcodes match the productId, even though they are the manufacturers productId and barcodes, even then some have different leading or trailing spaces
    it is also required to still be able to type the productId when required (damaged or no barcode), so changing all the productId to the scan value does not appear to be a realistic solution

    it looks like using serial mode would be simpler and safer than a systemwide keyboard hook, so i will start with that

    currently i do not have the third party software on the development machine, so i will have to test with that separately, to figure out sendmessage to correct window
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: translate barcode scan for external program

    Yes, I would definitely want to use the serial mode if possible. In general it should be very simple but there are some potential gotchas when dealing with MSComm and at least some USB serial port adapters. I have never had an issue when using on board serial ports or digi boards.

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: translate barcode scan for external program

    If the application doesn't expose something like an Automation API you'll have to resort to window spelunking and hijacking techniques. Even those fail if the application was written self-defensively using windowless controls or a self rendered widget library.

    Maybe just pay for a version of the application that offers macro scripting or an Automation API. If no such version is available then perhaps the vendor can suggest the best alternative for data injection. The vendor's user support forum might be the first place to start looking.

    Otherwise you're better off just configuring the device as a keyboard and using it in caveman mode. You don't get any "translation" that way unless the device itself supports on-board scripting, which is a pretty rare feature and may not meet your needs anyway if your translation involves a database or something.

    But there isn't any VB6 question here, just an application automation question and we don't even know what the application is.

Posting Permissions

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



Click Here to Expand Forum to Full Width