OK, I have a text box to be filled via a barcode scanner. We wish any other numeric keyboard input blocked. We’d prefer no other app code be used outside of Ignition if possible. I can block the keyboard inputs via java.util.EventObject scripting, but then the scanned value (10 digits) is not reliably seen before being rejected just as the individual typed characters would be.
I’m thinking if the scanner input could all come in (be buffered?), then I can bypass the rejection code if the input is 10-characters.
Is something like this possible perhaps using java.io.BufferedReader?
If so, I am unsure how to proceed.
I may well be over complicating it.
The blocking code I speak of is akin to below, on the text field keyPressed event handler
from java.util import EventObject
if event.keyCode== event.VK_NUMPADX or event.VK_X …etc where X is 0,1,2,3 …
# block the input , show screen message
As I said, keyboard input is reliably rejected.
I just need to allow the scanned “string” to be allowed
I have no specifics on the scanner being used other than it will likely be wireless.
I would be surprised if this will be possible with a keyboard-emulating scanner. Because they inject the keyboard scan codes you are blocking. Consider a serial or networkable unit to which you can make a non-keyboard connection. I believe in Linux you could also blacklist the scanner’s model codes to prevent its registration as a keyboard, then make a direct device connection. A bit of a research project.
1 Like
yeah, for now we use (2) text boxes. The first is very small, just big enough to place focus, font=1. Once filled, it populates an un-edittable box of normal size. That way a User cannot see anything they would manually type. Yes, a rogue user can still blindly type the 10-digits. We will pursue what you mentioned …thank you.
What I have done is to program the scanner to put a couple of characters at the start and end of the bar code. I then use a tag change script to pull the data from the string using the character sets as a beginning and end of good information. You have to come up with a set that you think would never be used or typed in. I usually attach the script to the tag being written to, and clear the tag once the script is completed. The trick with this is to have a bar code reader that can add the characters. Everyone I have used had that capability.
1 Like
If I’m interpreting this correctly, your issue is that you have a barcode scanner which is dumping text into a field on your display in the same way that a keyboard would; so you’re trying to differentiate between typed and scanned(untyped) input.
I think, as a simple, but maybe not comprehensive solution, you could put a timer on the text box. So if it receives a single character of input, and then doesn’t receive any other character within 1ms (or some small amount of time, faster than a human would type but slower than your barcode scanner dumps characters), then it empties itself. And then you would have to make it so that nobody can copy/paste stuff into your text field, because that would break the timing restriction.
Off the top of my head, another option is to set up the host machine running ignition so that it runs two clients and funnels all input from (whatever port the barcode scanner is plugged into) towards only one of the clients, and then funnels all keyboard input to the other client. This could be done using some fancy footwork on linux, or maybe a hypervisor or some other intermediary program on windows.
Finally, as a possible third option, I found this article about using Java hardware IDs to differentiate between multiple keyboards. You could potentially use something like this to tell which device the input is coming from, and then reject any input that doesn’t come from that device on your text field…
https://nanlee.wordpress.com/2013/06/12/manykeyboard-using-java-hid-api-to-handle-multiple-keyboard-input/
3 Likes