Generate Unique Barcodes Using Autohotkey

I love Macs, but unfortunately there are times that I have to use a PC, and what makes that time more bearable is an excellent program called Autohotkey. Autohotkey is a cross between Text Expander and Applescript on OSX, and lets you do simple things like create shortcuts for your email address, or more complex things like switching to another application, prompting for input, and using that input in the application.

It's generally a great way of adding functionality to one or all your programs.

A perfect example of where Autohotkey came to my rescue is when I was repeatedly testing an application that required a valid, unique barcode to be entered. The unique part was what caused the most problems as I soon ran out of things on my desk that I could steal the barcode from.

I therefore hatched a plan to use the current date and time as the first 12 digits of an EAN13 barcode, and then automatically calculate the check digit to put on the end, and this is the result.

:*:ean13:: 
now := "" 
FormatTime, now,,yyMMddHHmmss 
total := (SubStr(now,1,1) + SubStr(now,3,1) +SubStr(now,5,1)+SubStr(now,7,1) +SubStr(now,9,1) +SubStr(now,11,1) ) + (SubStr(now,2,1) + SubStr(now,4,1) +SubStr(now,6,1) +SubStr(now,8,1) +SubStr(now,10,1) +SubStr(now,12,1)) * 3 
Transform,remainder,mod,total,10 
check:= 0 
if (remainder > 0) { 
check:= 10 - remainder 
} 
send %now%%check% 
return

So now, whenever I need a barcode, I just type ean13 and voila, a unique (unless I'm really unlucky) barcode is sitting to the left of my cursor.

/
If you found this post informative, enlightening, entertaining, or it's just helped you solve a problem then please feel free to shout me a coffee for my trouble from extensive menu below:
Today's Menu