Auto tab to next text box after user scans barcode

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 11 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
graves
Posts: 8
Last visit: Thu Oct 08, 2015 8:48 am

Auto tab to next text box after user scans barcode

Post by graves »

Greetings everyone,

I'm trying to find a solution to a problem that I originally started in the Primal Forms forum. I was recommended to move the topic here.

I have provided the link to the original discussion but I will summarize below.

viewtopic.php?f=13&t=6432

I have a small form with three text box fields to collect information from three bar codes. I wanted to know how to automatically change the focus of the text box to the next field after the user scans the bar code which I have achieved with some help provided in the original discussion. To do this, I'm using the TextChanged event on the text box control to change the focus after the user scans data in to the field. The problem I'm running in to now is unless I specify a string length, the event is triggered after the first character is entered in to the box and the remaining characters in the string are ending up in the next text box. How can I auto-focus on the next field after the user scans the barcode without knowing the exact length of the string? The users are scanning various manufacturer serial numbers for computers and hard drives so the length of the string will not always be the same.

Here's an example of the functional code I'm using. Please let me know if there is anything else I can provide to be of any help. I have to enable multiline for txtBoxB if servers radio button is checked because the users have to scan more than one hard drive to this field. This is the only instance where they must manually tab to the next field because there is no way to indicate that they have scanned all the hard drives for the server chassis.

Thanks in advance for taking the time to read this. I do appreciate it. - Jason

########################################
$handler_txtBoxA_TextChanged=
{
if ($txtBoxA.Text.Length -ge 7)
{
$txtBoxB.Focus()
}
}
########################################
$handler_txtBoxB_TextChanged=
{
if ($radioBtnServers.Checked -eq $True)
{
$txtBoxB.Multiline = $True
}
elseif ($radioBtnClients.Checked -eq $True -and $txtBoxB.Text.Length -ge 7)
{
$txtBoxC.Focus()
}
}
########################################
$handler_txtBoxC_TextChanged=
{
if ($txtBoxC.Text.Length -ge 7)
{
$submit.PerformClick()
}
}
########################################
$submit_OnClick=
{
here the values of the text boxes are inserted in a template I have stored to memory and a
log file is created in a directory.

$txtBoxA.Clear()
$txtBoxB.Clear()
$txtBoxC.Clear()
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Auto tab to next text box after user scans barcode

Post by jvierra »

You must option the barcode scanning software to add a return after a scan. This is no the default but is the only way to trigger the form to tab to the next item. Thisis an issue to ask you vendor of barcode scanner devices about.
User avatar
graves
Posts: 8
Last visit: Thu Oct 08, 2015 8:48 am

Auto tab to next text box after user scans barcode

Post by graves »

Ahh.. I had not considered that. Although programming the scanner to enter a carriage return or tab did not work to change the focus, I ended up configuring it to add a space to everything scanned and use $txtBoxA.Text.EndsWith(" ") to execute the $txtBoxB.Focus() method. I'll just have to trim the space from the values upon submitting.

Thanks for your reponse, jvierra.

-Jason
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Auto tab to next text box after user scans barcode

Post by jvierra »

Here is a demo of how to handle the retrun at teh end of a barcode once it has been enabled in the scanner. Not all scanners add a return zafter the scan. ALmost all can be optioned to add a retrun or any termnating sequence including a tab. A tab is easiest.

Here is a bit of a demo that shows how to force a return to be converted into table like behavior.
Attachments
c416a989874e1b4ef8a0e436e24cb9.txt
(12.52 KiB) Downloaded 939 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Auto tab to next text box after user scans barcode

Post by jvierra »

Adding a tab or using the code posted is a far cleaner method.
I used to build nothing but bar scanner applications for about two years. This is a common issue. Almost all scanners allow adding a tab to teh output. Thisis the easiest and most common way to do this. A few rogue scanner (cheapo scanners) companies only allow a return sequesnce of lf,cr or lfcr. When thisis the case use crlf and use the trap code on all textboxes to force a termination of input and a move to the next item.

The way we handle the multiselect is to provide a code scan page somewhere. I used to stick it on the prep tables and make it big which has a single barcode which was blank and forced a tab to be sent. The blank entry was the key to terminate variable input.

In most cases we always used self identifying barcodes . ALmost all industry barcodes are like this. Using this technique we can detect all input from a device and send it to the proper field. Order of scan is nver an issue this way and we can do miultiscans at any time. A specisal coded barcode complertes the entry ("SUBMIT:ALL")

This is the correct way to design hands-off scanning. The user should almost never touch the keyboard. Thisis required for almost all medical aplications like sample logging at laboratories. All entry must come from the materials. This is pretty much the only way to validate that an item has been catalogued/received correctly.
User avatar
graves
Posts: 8
Last visit: Thu Oct 08, 2015 8:48 am

Auto tab to next text box after user scans barcode

Post by graves »

jvierra - This is great information. Thank you. I got everything working almost the way I wanted. I configured the scanner suffix with the ascii horiz tab code and used $txtBoxA.Text.EndsWith("`t") to reposition the focus. For multiple scans I just split the tabs to store each item in to an array for how I need to process them. Thanks for the added info on handling the multiselect for multiplehard drives. Worked like a charm. I used the keyword EXIT`t to print a barcode to break out of the multiline box. I know this is probably not what you intended with your suggestions but I couldn't adapt the code you provided for my project. All of this (powershell, forms, etc) is really quite new to me and I'm pretty much flying by the seat of my pants here. Unfortunately I had to have something "working" by COB today.

Really, thank you very much. Everyone here has been a big help and I'm grateful for that. I'll be sure to revisit this project in the future as time permits. Now on to other things.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Auto tab to next text box after user scans barcode

Post by jvierra »

The ending tab should automatically terminate input and move you to the next box. YOu do not need to trap teh character. You shoyuld not need to process any characters at all.

A standard form set to defaults with terxtboxes set to defaults will always select when a tab is received. We use that all of the time to scan data into receiving forms.

The EXIT is ok. It only has to be guaranteed to not be a field on any form used on the screen. I have used END_OF_BATCH to do this. This requires making the controls swallow and react to the return code. (`r)

However you do it is good but remnember that too much code can become an issue of support. If it is a one time form then it is not likely an issue.

The national barcode people have a web site with a set of standards for barcode usage including forms entry.

http://www.amerbar.com/university/dictionary.asp

Of course every industry has their own additions to this.
This topic is 11 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked