AppleScripting Google Desktop

Thursday, June 28, 2007 at 5:49 PM

Posted by Dave MacLachlan, Mac Software Engineer

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

This will return an array of search results. A search result is a record containing the title, snippet, and URL of the result, along with other details. So if you wanted to display just the title of the first result, you could do this:

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

Or if you wanted to open the first result:

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

The "search for" command has several more powerful options, some of which are exclusively available in the scripting interface. Suppose you want to search for results between two dates:

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.

Congratulations Amit, the Mac team is proud of you!

Thursday, June 07, 2007 at 5:31 PM



Picasa Web Albums meets Google data APIs

Tuesday, June 05, 2007 at 6:17 PM

Posted by Greg Robbins, Mac Software Engineer

My parents enjoy it when I bring them printouts of my favorite photos, but the rest of my family and friends are happier just to get links to the pictures. With the Mac uploaders for Picasa Web Albums, it's quick and easy to put my photos on Google's servers.

But there's a lot more to share besides snapshots. Maybe you've created an avatar for your online world and you'd like to show your creativity to friends who live "outside." Or consider this: security cameras and webcams can capture suspicious activity. Those could go into a Picasa Web Album, and be monitored like any other RSS feed. Almost every Mac application can extend its reach by sharing online. And with Google Data APIs, there's no need for a specialized server. Any application can let you share your data with your Google Account.

Now that Picasa Web Albums has a Google data API, I've updated the open-source Objective-C Client Library to make it easy for developers to share photos from their applications. Here's what it looks like for a programmer adding the picture SunsetPhoto.jpg to the album "My Best Photos":

GDataServiceGooglePicasaWeb* service =
[[GDataServiceGooglePicasaWeb alloc] init];

[service setUserCredentialsWithUsername:@""

// get the URL for the album
NSURL *albumURL = [GDataServiceGooglePicasaWeb
picasaWebFeedURLForUserID:@"my.account" albumID:nil
albumName:@"MyBestPhotos" photoID:nil kind:nil access:nil];

// set a title and description for the new photo
GDataTextConstruct *title, *desc;
title = [GDataTextConstruct textConstructWithString:@"Sunset Photo"];
desc = [GDataTextConstruct textConstructWithString:@"A nice day"];

GDataEntryPhoto *newPhoto = [GDataEntryPhoto photoEntry];
[newPhoto setTitle:title];
[newPhoto setPhotoDescription:desc];

// attach the photo data
NSData *data = [NSData dataWithContentsOfFile:@"/SunsetPhoto.jpg"];
[newPhoto setPhotoData:data];
[newPhoto setPhotoMIMEType:@"image/jpeg"];

// now upload it
GDataServiceTicket *ticket;
ticket = [service fetchPicasaWebEntryByInsertingEntry:newPhoto

The new library includes sample code that shows developers how to browse albums, add tags, display upload progress, and take advantage of the full Picasa Web Albums API. So now you can encourage the developer of your favorite application to make it easy and free for you to share your work online, too.

Google Desktop for the Mac 1.0.3

Friday, June 01, 2007 at 9:11 AM

Posted by: Rose Yao, Mac Product Manager

Just wanted to let everyone know about a new update for Google Desktop for the Mac. We've been reading your emails, blogs, and comments, so we focused this update on making Google Desktop faster and fixing the bugs that we hear the most about. We have also updated Google Updater in this release with a lot of great bug fixes. You can check out our release notes for more details. If you have Google Desktop installed, you don't need to do anything to get the update, we'll deliver it to you automatically. If you want to try the latest version of Google Desktop, go to

P.S. For all the Mac developers out there, we've also added a new XML based query API that is supported on the PC and the Mac. Learn more about it!