AppleScript Fun

I’ve been playing with AppleScript. It’s startlingly easy to get a handle on and even easier to get very cool results which is perhaps why I like it. AppleScript is a computing glue that connects different applications together and allows you to use their functionality for your own evil ends.

My first Applescript was a quick knocked up icon to sit in my dock and start when clicked. This is what it looks like:

tell application “Finder” launch application “X11″ end tell

set results to do shell script “cd ~; DISPLAY=:0.0; export DISPLAY; PATH=$PATH:/Applications/OpenOffice.org1.0.1/program; export PATH ; /Applications/OpenOffice.org1.0.1/program/soffice > /dev/null 2>&1 &”

You see, it looks more than a little like english which is perhaps why I like it. And even better you can make your AppleScript look like a real application, I gave mine a swish OOo icon. For very little effort you get a whole lot of payoff.

After I told him about this Ben sent me an AppleScript he’d done to automatcially send a page to his blog when he said ‘Blog This’. It’s pretty cool, correction it’s more than cool. AppleScript studio even has an easy way of doing XML-RPC for goodness sake, if someone with as little knowledge as myself can design their own blogging app with 20 minutes effort there’s something deeply, deeply right.

Anyway, back to the story. I started playing with this and ’speakable items’ today but couldn’t get it to work consistently. I went into the diagnostics and fiddled with the settings, that’s where it hit me. I was speaking English and the program expected English! Or in other words, I’m not American.

After much vocal experimentation I discovered that Speakable Items seems to have been calibrated against and unholy cross between Viggo Mortensen and that guy who does the voiceovers for movie trailers. So with my new deep and slightly laconic voice I intoned “blog this” and lo! It did.