Mail, Applescript and Quicksilver Triggers

This morning was my first foray into the world of Applescript, and it was surprisingly painless. My basic need was to have a key shortcut for each of three tasks that I do continuously in Mail in a semi-GTD fashion:

  • Mark a message as Unread and move it to my @Action folder
  • Mark a message as Unread and move it to my @Hold folder
  • Move a message to my @Archive folder

After a little research I found various scripts that did small parts of these tasks from which I gleaned my first working scripts for

Here’s the @Action script

tell application "Mail"
    set s to selection
    repeat with eachMessage in s
        set read status of eachMessage to false
        move eachMessage to mailbox "@Action"
    end repeat
end tell

Fairly simple really, eh?

Shortcut keys

My next task was to get to recognise the scripts and find a way to assign key shortcuts to them. I tried getting the scripts to appear for about 5 minutes before I figured that the best way to get key shortcuts working would be to use Quicksilver triggers.

Thankfully Quicksilver also has scopes for it’s triggers. This worked perfectly for my scripts. I simply created the trigger, set the key combo and specified the scope to only activate this trigger in Mail. No overloading of key combos, no moving mail messages around when I’m using other programs, no fuss.

The keys I used were cmd-shift-A to Action, cmd-shift-R to Archive and cmd-shift-H to Hold. I tried them out before assigning them and got the reassuring “bing” confirming they weren’t already active combos.

The upshot

Using this method I can now instantly move my selected message(s) into whichever folder I need to and keep my inbox clear. The half an hour or so of research and coding will save me untold hours over a long period of time and it also pleases the geek in me that I’ve consigned yet another task to the keyboard, pushing my mouse and trackpad further into obscurity.