AppleScripting Google Desktop
June 28th, 2007 | Published in Google Mac Blog
Most people aren't aware that Google Desktop has a simple, but powerful, AppleScript interface. You can use this interface to write scripts that search with Google Desktop. The most basic script allows you to quickly search for some text:
tell application "Google Desktop"
search for "happy"
end tell
tell application "Google Desktop"
set results to search for "We wish"
set a to title of item 1 of results
end tell
display dialog a
tell application "Google Desktop"
set results to search for "you a"
set a to URL of item 1 of results
end tell
open location a
tell application "Google Desktop"
set startDate to date "Monday, July 17, 2006 00:00:00 "
set endDate to current date
search for "happy" after date startDate before date endDate
end tell
Or, let's say you want to find only email results:
tell application "Google Desktop"
search for "birthday" restrict to email
end tell
Or, finally, you'd like to do an exact search (as opposed to a prefix search, which is the default):
tell application "Google Desktop"
search for "hoff" without prefix match
end tell
Of course, you can use all of this directly from the command line using osascript.
There are several other options for "search for" and a few other simple commands hidden within the dictionary, so poke around and see what you can do.