For a while, I've been using handy Quicksilver triggers to control iTunes. I like not needing to switch my attention from what I'm working on, in order to skip a track, pause the playback, set a rating or whatever. You can find out how to create a trigger from one of the many great Quicksilver tutorials out on the Web.

At the moment though, I find myself listening to Last.fm more and more, and have been looking for a similar way to control the Last.fm application. I couldn't find a plugin for Quicksilver to achieve this so I set about writing an Applescript which I could trigger with Quicksilver. I'm not much of an Applescript whizz, but I managed to put the following script together to skip the track currently playing in the Last.fm application:

tell application "Last.fm" to activate
tell application "System Events"
        tell process "Last.fm"
                click menu item "Skip" of menu "Controls" of menu bar 1
        end tell
end tell

After saving this in a suitable location (I have a Utils folder where I keep lots of scripts and utilities), I set a Quicksilver trigger to run the script. Simple! Happy with the result, I created similar scripts for some other controls like love, ban, play and stop and assigned them all keyboard triggers.

My only wish was that I could do this without giving Last.fm focus. Generally this is fine for my because I have it running in a second display, so it doesn't steal my attention, but it would be nice if I could get Applescript to execute the command without activating the application. I'd welcome suggestions from anyone with more Applescript fu than me.