How-to: Create Services for Quick Search Box


I’ve been playing around with Google Quick Search Box lately and am especially enjoying this services plugin from Martin Kuhl which lets you activate and pass input to OS X services right from within QSB.

One snag though has been that services created through the new Automator template included in Snow Leopard leave out some vital bits that limit integration. Luckily, a handy application from Waffle Software called ThisService makes creating proper services that integrate seamlessly with QSB a lot easier than you might think.

Being able to extend the functionality of QSB with OS X services really opens up a lot of possibilities. Grab text or files in QSB and pass them on to your services to do whatever you want with them, like creating a new To Do item in iCal. I’ve been focused recently on replicating functionality that I lost when I made the switch over from Quicksilver and I think that this improved service integration will get me about 90 percent of the way there.

The bad news is that this means I need to whip up a bunch of custom services for myself. The good news is that ThisService makes that task very easy. Just give it a script (AppleScript will do, but if you’re more comfortable with other scripting languages you can use those), define the type and name of your service and click Create Service. ThisService handles all the fiddly Cocoa bits and spits out a completed service into your ~/Library/Services directory where QSB will see it and serve it up as an available action when appropriate.
Actually writing your AppleScript will likely be the most complicated part, which is why ThisServices comes bundled with some handy starter scripts to put you on the right path. They also make a number of example scripts and services available for download from their site. The scripts don’t need to be complicated. For example, here is the one I use for adding To Do items in iCal:

[sourcecode language=”csharp”]
on process(input)
tell application "iCal"
tell calendar "work"
make new todo at end with properties {summary:input}
end tell
end tell
end process

If you wanted to get fancy you could pass additional properties like the due date, priority, etc., but just getting a new item into the list is all I need.

Once you have your service setup accessing them through Quick Search Box is as easy as can be. Because showing seems to be more useful than describing, below is a quick little video clip of the To Do service in action. What kind of services would you like to have? Share your thoughts in the comments.