Jump to content

Listen to barcode input on non-Autoit active form.


AhGohGoh
 Share

Recommended Posts

Hi! I am new to AutoIt.

I am working on a project. There is a program call "Production" where we use barcode scanner to scan our Job Number which is in barcode format to "check-in" into the multi-coat department. Our customer service are able to check the job process status then.

We have 3 types of multi-coat. My intention is to create a hidden form (in system tray) to listen to barcode scanner input whenever this "Production" window is active. I will use this input to check from our database server for the type of multi-coat to help them to separate type of multi-coat by playing different sounds.

AutoIt Window Info unable to get the controlname for the textbox which forcing me to listen to barcode scanner input.

I have did search and tried on RawInput.au3 but don't know how and unable to get the input from barcode scanner.

My barcode scanner is Symbol LS2208 UBS type.

Can someone help me with example how to listen? I only need to listen when the "Production" program is active.

I understand that it like keylogger but I swear I am not using it for hacking.

Thank you in advance.

image_2022-12-30_154725380.png

Link to comment
Share on other sites

Why did you put it in AutoItX ?  You should ask a mod to move it to GH&S, I believe.

Do you see your barcode scanner as a device when you use _WinAPI_EnumRawInputDevices ?

It is suppose to emulate keyboard entry when you scan a bardcode, right ?  If so can you scan a few barcodes, put it in Notepad, save it to file and post the file.txt here so we can see what the messages looks like.

Edited by Nine
Link to comment
Share on other sites

Thank you for your response @Nine.

I have to say sorry first as I am not a "qualified" programmer. I learn programming by myself as a habit and I am using my working environment as an opportunity to try out my programming skill.

Due to that, I don't understand the meaning of "ask a mod to move it to GH&S". However, I will google for the meaning.

Come back to topic. I use below code to check the device:

#include <APISysConstants.au3>
#include <Array.au3>
#include <WinAPISys.au3>

Local $tText, $aData = _WinAPI_EnumRawInputDevices()

If IsArray($aData) Then
        ReDim $aData[$aData[0][0] + 1][3]
        $tText = DllStructCreate('wchar[256]')
        For $i = 1 To $aData[0][0]
                If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tText, 256, $RIDI_DEVICENAME) Then
                        $aData[$i][2] = DllStructGetData($tText, 1)
                Else
                        $aData[$i][2] = ''
                EndIf
        Next

EndIf

_ArrayDisplay($aData, '_WinAPI_EnumRawInputDevices')
 

And my barcode scanner device is #1 (See below).

image_2022-12-31_085307233.png.32efbb028196cafe07231dae298d0125.png

For the requested barcode text file as attached.

I also snipped few barcode for your reference, if needed.

1457913422_BarcodeSample.jpg.5b7529cbd008b1b30960b521af24445f.jpg

Thank you again.

file.txt

Link to comment
Share on other sites

Interesting.  Your device is considered as a keyboard from the system.  So it will be very easy to identify what is the input from the barcode device and the real keyboard.  I understand that you are not familiar with programming but you can look at my signature to find a UDF called Multi-keyboard HotkeySet.  You can start with this code to find how to differentiate a key entered from one of the 2 devices.

You cannot use my UDF directly, but the code inside is pretty much what you need.  Now, you must understand that we are not here to write code for people  We are here to help people when they have issue with their code.  So put something together and come back with the code that is not working.  Please when you post code, use the appropriate way as described in the link.

ps.  "ask a mod to move it to GH&S" means that you posted your request in the wrong forum.  In full work, it means "Ask a moderator ( @Jos @Melba23 ) to move your thread into General Help and Support Forum", since your request has nothing to do with AutoItX.

Link to comment
Share on other sites

  • Moderators

Thread moved.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

A barcode scanner basically is a keyboard, so "listening" to a barcode scanner is technically a key logger.  Pls read up the Forum rules which explicitly prohibit this.

 

Technically (if you already know how to "listen" to your barcode scanner) it's quite easy to catch barcode scanner input, as all barcode scanners send their data at a fixed rate of "keys-per-second" and no human input will ever provide the same and constant key rate per second.

But to fill in the barcode scanner input to a certain input box or edit, all you need is to put the focus on that control and then scan the barcode. Then the input will be filled into that control or edit.

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Thanks @rudi for your reply.

I'm still struggling on the "listening" function. 

My plan is:

if WinActive("Production") Then
    $bBarcode=ListenToBarcodeScannerInputData
    $mMulticoat= SqlQueryForMultiCoatType($bBarcode)
    If $mMulticot="Green" Then
        Play"GreenSound"
    Endif
    If $mMulticot="Blue" Then
        Play"BlueSound"
    Endif
    If $mMulticot="Drive" Then
        Play"DriveSound"
    Endif
EndIf
loop again

I'm fully understand "Listening" is a key logger. But I need "this" to do some control and sorting as our workers facing more than 1000 jobs per day and human make errors. I just wish to cut down the errors.

I have successfully did the other way round where I created an input form using AutoIt. Then I will use sendkey to copy the input and paste to the "Production" form and sendkey "Enter" at "STATUS4". (Please see above picture).

But now our Production Manager has changed the "Production" screen as below for batch control purpose. That is why I need to use the "Listen" function.

image.thumb.png.652c5671c37e87987d1de253c25a7303.png

Any tips on the "Listening". I just need this one "$bBarcode=ListenToBarcodeScannerInputData".

Thank you again

Link to comment
Share on other sites

To be honest, I do not understand what is the issue you are having.  In the form you posted, there is input fields containing SCANJOBNUMBER.  Why don't you put the barcode scan directly into those fields ?

One thing I believe is that you do not need to read raw input data (way an overkill).  You just need to use an input (or edit) field to receive the scan code...

Link to comment
Share on other sites

Sorry. My bad. I don't stated clearly.

The form with "SCANJOBNUMBER" is not created by me. It is the "Production" program form, which I don't have the textbox controlname. (I have tried to use AutoIt Windows Info to scanned it but no info on the textbox).

My company is producing spectacle lenses (in our industry we are called RX Lab). In the Multi Coat Department, we are processing (or coating) 100 pieces of lenses per batch and our production manager using the (A), (B), (C), (D)....... to identify which processing batch of a lens for troubleshooting purpose, if required later.

Each order normally contains 2 lenses (Right & Left for both eyes). But sometime an order may only contain 1 lens (either Right or Left eye).

(At this stage, I don't want to use AutoIt to do the counting (100 pieces) as there is other criteria affecting the counting, Example product "Reject" or "Damage". )

So for the moment, I just let the workers to select (A), (B), (C), (D)...... manually.  My planed is to "Listen" to the barcode scanner input and help them do the sorting using sound.

p/s: When Multi Coat Department received the lenses from previous departments, they are not sorted.

It is alright if you understand me. I will try to find the how to "Listen".

Link to comment
Share on other sites

As @Nine already suggested, the best way is to put the string coming from the scanner directly into the appropriate control.

What do you see with the Autoit v3 Window Info Tool, when you drag-drop the crosshair to the control you want to select?

Possibly the form you are talking about was coded by an inhouse programmer? Then you could ask him to set the control focus to a certain control and then TAB through the controls.

Or there is a different possibility to send the input to your ERP system directly, without that form

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...