Automating things

I’ve got some homegrown OSX Automator services for tracking packages in Australia Post or DHL. For an online shopping addict it’s helpful to just select the tracking number, right click, select the shipping service and head off to the site.

Recently I’ve been trying out the Safari Technology Preview and had changed my default browser. It seems that the original implementation of my services used AppleScript to directly call Safari instead of the default system browser. It was time to update the scripts!

The hard part was finding them. Spotlight wouldn’t show me the services themselves (they’re packages), but I did find a way to get there. Open System Preferences then Keyboard then select Services. Scroll to find your service…

system preferences-keyboard-services

Then right/option click on the item and select open in automator. open in automator

The original script was convoluted but worked - use Javascript to build the required URL, then take the input from that and run the following AppleScript:

on run {input, parameters}
  tell application "Safari"
    open location input
  end tell
  return input
end run

This was a little hacky, so as I mentioned at the start of the post I’ve updated it to use the default browser. I just run the shell command open ""$1

full script

I realised after doing this that I could inadvertently select some code which will nuke my hard drive, so I added a few checks.

If you want to use the service, I’d suggest implementing it yourself to learn, but the code’s available here too: Track Parcel with Australia Post. Extract the .zip file, then double click it and it should give you the option to install the service

#OSX #Automator