Monday, February 2, 2015

AutoHotkey'ing Stamps.com

I love the Stamps.com app. While their XML import format was a little obscure, once I got it working, I was able to use it to print thousands of labels, save myself a nice chunk of change on shipping, and mail all my backers tracking links.

But now that the main pulse of Kickstarter shipping is over, I'm using it to send out individual packages on a daily basis, and getting the address information for a customer into the app meant cutting and pasting from a web-based shopping cart system (I am using the Ubercart Drupal module).

It's not a big deal, but it does get repetitive, and being an extremely lazy person, I will go to extreme lengths to avoid such activity. So over the last month I've created and tuned some automation to interface the web form with the Stamps.com app.

The solution involved using an interesting (and free) scripting application for Windows called AutoHotKey. This lets me write little programs that can be invoked by keypresses and which can interact with the UIs of other programs.

Using AHK, my workflow now looks like this:

  • Click on an invoice in my webapp (I'm using Chrome but any browser will work). Ctrl-A then Ctrl-C to copy all the text in the page.
  • Bring up either the domestic or international manual batch label entry dialog in the Stamps.com app.
  • Ctrl-Alt-V to invoke an AHK script that parses the text in the copy buffer, extracts the name, address, phone number and email address, does format corrections for some international addresses, and then pastes it all into the correct fields in the Stamps.com dialog.
  • Hit another AHK hotkey to define what I'm mailing (for example, Ctrl-Alt-P means "I'm mailing a Bubblegum Crisis Premium set"), and set the weight, mail class, and if international, default customs information.
  • Save the label.
  • When I've done all the labels, print them as a batch.

Before AHK, I was spending about 2 minutes per label. Now it's maybe 20-30 seconds. Given how long it took me to write the script, I'll break even in about 500 labels.

You can find my script here; after you've installed AHK, just drop it in your Documents folder and AHK will find it. You'll obviously have to tweak the parser and the definition hotkeys to fit your preferences, but that should be relatively straightforward.

Enjoy!

No comments:

Post a Comment