09.04.07

Unexplored territory

Posted in Camino at 12:13 am by Smokey

This weekend Bug 390846 - Camino AppleScript Support: Bookmarks landed. This code is phase 2 of Peter’s three-phase project to improve Camino’s AppleScript support this summer. As always when something new lands, I like to spend some time playing with the feature. The funny thing about AppleScript, if you’ve never spent any time with it, is that AppleScript is almost, but not quite, English (see the “Interpolation” section of this John Gruber article for more about this). As a consequence, learning to script a given app or a given feature sometimes requires a bit of trial and error; it’s definitely something you learn.

In spite of what Gruber says about AppleScript, I’ve always been fond of it because it’s really the only computer language I’ve been able to understand enough of in a short enough time to do something useful. I’ve been writing AppleScripts off and on for over a decade to perform small, useful tasks (among them Troubleshoot Camino). For the longest time, I’ve been scripting the same things (the Finder, System Events, Eudora (the old-school version that actually works), some do shell script and folder actions; I have good grasp on the vocabulary and have wrangled the English-likeness monster in those areas.

With Camino’s new AppleScript support, though, I’m back in unexplored territory. After so long, I’d forgotten about the poking around and trying different permutations to get the scripts to do what I wanted them to do. However, it has been a fun exploration, creating bookmarks, invoking them, and learning the limitations of the new dictionary (and triggering some bugs along the way). I don’t yet know what sort of useful things I’ll do with the new bookmark support—invoking the Mouseover DOM Inspector on the current page via AppleScript makes a cool demo, but I can’t figure out why that would be practical—but I am looking forward to trying. It’s a vast new county out there, and now that I’ve remembered to keep trying different combinations of commands and classes, I’m off to explore some more! :-)

Here are a few sample scripts to get you started:

tell application "Camino"
	make new bookmark with properties ¬
		{name:"My First AppleScript Bookmark", URL:"http://www.caminobrowser.org/help/", shortcut:"scriptmark",description:"My first Camino bookmark created by AppleScript"} ¬
		at end of bookmark bar collection's bookmark items
end tell
tell application "Camino"
	set the URL of the current tab of browser window 1 ¬
		to (URL of bookmark "Mouseover DOM Inspector" ¬
		of bookmark folder "WebDev" of bookmark folder ¬
		"Bookmarklets" of bookmark bar collection)
end tell
tell application "Camino"
	count bookmark items of bookmark folder "Searches Collection"
end tell

Grab your scripting boots and enjoy!

Leave a Comment