Barcode Scanner to trigger macro

Hi, is it possible to have a barcode scanner trigger a macro? I imagine this is largely dependent on the type of barcode scanner you have. The main hangup I’m discovering is that our barcode scanners are programmed to simulate ‘return’ key after scanning a barcode. I cannot change this as we depend on scanning barcodes. I tried creating a typed string trigger using %W%, but the simulation of Return key after scanning that barcode causes issues. Any ideas? Thanks!

There is no specific event that is available to detect this.

I suspect you could hack something by doing this:

Macro 1:
Trigger: Typed String trigger on regular expression \d{6,} (presuming just numbers in the bar code, and presuming at least six digits, adjust regular expression as necessary).
Action: Set variable “Barcode” to “%TriggerValue%”, Set variable “When” to calculation “NOW()”

Macro 2:
Trigger: Hot Key: Return
Action: if calculation NOW() - When < 0.3 then do stuff with variable Barcode

It wouldn’t be perfect and could have false detection cases and such, so it would depend on how the Mac was used other than for barcode scanning.

Hmm, yeah, definitely seems complicated. Looks like I’ll need to read up some more on calculations. Thanks!

Hi @music4jimmy

I used to trigger a macro with a barcode scanner. In my case I was using Regular Expression for triggering.

Note: My code was always consisting of digits - Code 39 (Regular Expression can be modified for your needs)

See screenshot Below:

I'm not familiar with the regular expressions, but I need something similar.
When I scan in an EAN number of 13 digits they always start 503 then there is an additional return that I would like to remove so that I can copy the EAN it to the clipboard first.

I use it to rename a file but then sometimes need to copy it to another file.

Can you help me with this?

I did get this to work


Seams to work ok, is there anything that I have forgotten?