Input from barcode reader

Hi, I wanted to control and manipulate the input of a barcode reader with Keyboard Maestro. Right now it scans with " ̈o" as a prefix, so I can use that in a string trigger. But how can I save the rest of the code in a variable for later use?

Thanks :slight_smile:
Trond

I'm not sure if the Typed String trigger can detect the " ̈o" character, but presuming it can, and assuming either the number of characters read is fixed, or there is some trailing character, then you can use the regex variant of the Typed String trigger to capture the whole thing, and then use the TriggerValue token to extract the code.

Hi Peter, thanks for the quick reply! Here is where Im at right now, this displays just the prefix " ̈o" character. To have the regular expression match capturing the whole thing must I also somehow define what comes after the prefix?

Thanks
Trond
23

Yes.

What does the remainder of the barcode look like. Does it have any terminating character or any fixed length?

Its not fixed length, either it has 5 characters then "-" then 1 to 3 characters or it has 6 characters then "-" then 1-3 characters. Examples 41000-1 or 200100-59. The scanner can be set up to have different pre and suffix, so I can terminate with for example enter.

Trond

Could the suffix be set to "#" ?
Then then trigger could be set to " ̈o" + everything until the "#" is typed.
This is then in the trigger value and you can search and replace for " ̈o" and "#".

1 Like

Hi Jimmy, I'm pretty sure that's possible, I will check and report back, what would be the code to make that happened?

Thanks alot :slight_smile:

Trond

I think the string typed should be " ̈o.+#"

Then I would set a variable to the %TriggerValue%.
Search and replace for " ̈o" and replace with nothing for that variable. Do the same with "#".
And the do whatever action you need with the variable.

Hi, sorry for the late reply! I managed to get Return in as the suffix. And then try to trigger with [ ̈o.+/r] but it doesn't seem to trigger it and Im also not sure how to proceed with defining the variable via the %TriggerValue%

Thanks again!
Trond

Hi Trond

Try the macro below and see if it just diplays your barcodestring.

Keyboard Maestro 8.2.4 “Test barcode trigger” Macro

Test barcode trigger.kmmacros (4.1 KB)

1 Like

That worked perfectly! And I could just switch the display text to a copy text to clipboard which was my destination.

Thank you so much for your time :smiley:

That is good.
Remember to mark the post which solved the problem as the solution to help other in the future.