Automating Things
CulturedCode’s Things is probably one of the best GTD applications available on the Mac OS X and the iPhone platform. Yet, there really is no alternative that supports managing your tasks in such a big scale like Things does. I know Potion Factory’s The Hit List as well as I know Chandler, Midnight Inbox and others – but they all kinda lack of specific features or just don’t integrate that good into one’s everyday workflow. I would really love to see The Hit List being developed more active and finally provide an iPhone client that might beat the crap out of CulturedCode’s Things bundle, which yet still doesn’t allow me to keep each client in sync via MobileMe/without being in the same network or using Dropbox for desktop-to-desktop sync.
However, since (at least for me) there’s nothing comparable to Things, I’m trying to benefit from using it the best I can. One possibility to do so is the automation of task-creation. Wouldn’t it be cool to have Things automatically pack specific e-mails together as tasks you would only need to get done – without actually having the trouble of importing the information from Mail.app manually into Things first? I solved this problem for myself by using a feature that Things, Mail.app and Mac OS X provide me by default: AppleScript.
Now, how would this automated task-creation look like. First, a piece of code is needed, which gets the specific information out of an e-mail and tells Things to add those information to its library. The CulturedCode Wiki already provides us such a script and first I’ve tried to use that. Unfortunately, the script seems to be something hacked together with Apple’s Automator and interferes with the UI, what causes the process of task-creation to be visible to the end-user. I didn’t want that – so I just hacked together my own AppleScript using the AppleScript Edior:
on perform_mail_action(info)
tell application "Mail"
set selectedMessages to |SelectedMessages| of info
set theRule to |Rule| of info
repeat with eachMessage in selectedMessages
set theSubject to subject of eachMessage
set theContent to content of eachMessage
tell application "Things"
set newToDo to make new to do with properties {name:theSubject, due date:current date, notes:theContent} at beginning of list "Inbox"
end tell
set the (read status) of eachMessage to true
end repeat
end tell
end perform_mail_action
You can simply copy & paste this code into your AppleScript Editor and save it somewhere in your filesystem as AppleScript.
Next, we need this script to be called as soon as a new mail arrives. Let’s use Mail.app’s “Rules” for doing that!
As “Run AppleScript” the script you’ve saved before needs to be specified. What rule you use for yourself actually depends on your incoming mails. In this example, I’m checking the mail’s subject to contain the string [ToDo]: for the script to act on that e-mail. Of course, you can also add another action *after* the “Run AppleScript” for Mail.app to delete the mail afterwards. The only thing my script does is to mark the mails that matched as read.
Now try it out on your own. Write yourself an e-mail containing your match-criteria and you’ll see that the script will automatically add a new task within your Things’ Inbox, containing all details from within the mail itself. Of course, this script can be enhanced for example by leaving away the match-criteria from the subject (s/matchpattern//g), by cutting off everything after “– ” (signature) or maybe even delegating the task to a co-worker or an area of responsibility by parsing the mail’s body. Feel free to extend it the way you need it. :)
PS: You can make the Inbox entries not being due by today by simply removing the “due date:current date” parameter from the script.
//UPDATE:
Because this whole automation topic is so much fun, I’ve just written an AppleScript that automatically adds every conversation-line you receive that starts with the pattern “task: ” to your Things Inbox. :)
Here’s the AppleScript:
using terms from application "iChat"
on message received theMessage from theBuddy for textChat
set theBuddy to full name of theBuddy
if theMessage starts with "task: " then
tell application "Things"
set newToDo to make new to do with properties {name:theBuddy & ": " & my LeetReplacer((get theMessage), "task: ", "")} at beginning of list "Inbox"
end tell
end if
end message received
end using terms from
on LeetReplacer(strng, srch, replc)
tell (a reference to my text item delimiters)
set {old, contents} to {contents, srch}
set {strng, contents} to {strng's text items, replc}
set {strng, contents} to {strng as Unicode text, old}
end tell
return strng
end LeetReplacer
And here’s how you can include it into iChat:
Enjoy!
About this entry
You’re currently reading “Automating Things”
- Published:
- 2.21.10 / 4pm
- Category:
- Mac and stuff ..., New & Cool, Programming
- Tags:
- AppleScript, Automator, Chandler, Dropbox, GTD, Hacking, iChat, iPhone, Mac, Mail.app, Midnight Inbox, MobileMe, The Hit List, Things
- Read it:
- On your mobile device.


2 Comments
Jump to comment form | comments rss [?]