Archives
Admin / Logout

Adam Merrifield

a picture of me
I am a theme developer, a coder and internet personality.

what i am

I am the owner and operator of seyDoggy Systems, a small theme, code and design outfit based in Kitchener, Ontario, Canada. We primarily develop web based technologies but have begun to dabble in the desktop realm.

what i do

I code like a fool. I design like a fool. I am happiest when I can split my time between the two (though I tire of Photoshop faster then I do Sublime Text 2 or Terminal), and somehow I have managed to etch out a living doing so.

Scripting LittleSnapper

[Scripting LittleSnapper][ls]I hate clutter in my Dock… I also hate being slowed down looking for things. You can imagine these two positions are at odds with each other quite often. I don’t use the Dock in Mac OS X as a place to launch apps so much as I use it as a visual reminder of the things I can do, but don’t on a regular basis.

Like [LittleSnapper][ls] for instance. I use it maybe once a day, and for pretty much the same thing — I open it up, I snap the current web page and then proceed to tag it, rate it and upload it to my [ember Pro][em] account — but I don’t keep it open. I quit LittleSnapper when I am done and cary on with the rest of my day. This kind of usage doesn’t warrant a coveted position in my Dock, but if I have to search for the app (Spotlight, Google QSB, QuickSilver) or dig for it in Finder, the inspiration to snap that web page may well pass.

So what does a magna nerdulosa like myself do to address this situation? I automate! AppleScript to the rescue!

The first thing I want to do is launch LittleSnapper and I do that by tossing a little bash in AppleScript using the following:

tell application “LittleSnapper” to activate

And now LittleSnapper is ready to have it’s buttons pushed[*][buttons]:

tell application “System Events”
tell process “LittleSnapper”
click menu item 1 of menu “Capture” of menu bar 1
end tell
end tell

It’s as simple as that! The full script will:

* Luanch LittleSnapper
* tell LittleSnapper to go into the “Capture” menu
* click “Snap Web Address from Safari”

You can then cary on with tagging, annotating or whatever else tickles your LittleSnapper fancy.

## Now what? ##

For me the next step is to save the script in `~/Library/Scripts/` add a hot-key combo to it using [Red Sweater Software's][rssw] [FastScripts.app][fsa]. You could also use this in [LaunchBar][lb], [QuickSilver][qs], [Butler][btlr], or any other means you may use to run AppleScripts.

## Full Script ##

– This script launches LittleSnapper

– and tells it to snap the current web page

– By Adam Merrifield
– r4 10-08-09 08:12 (removed delays)

tell application “LittleSnapper” to activate
tell application “System Events”
tell process “LittleSnapper”
click menu item 1 of menu “Capture” of menu bar 1
end tell
end tell

## Download ##

[Get it fresh from CodeCollector.net][ccdn]

## Notes ##

* this exact sequence of commands could change if Realmac Software ever changed LittleSnapper’s menu layout, but I prefer this shorthand over the verbose menu item selections.

[buttons]: http://www.seydoggy.com/2009/09/30/scripting-littlesnapper/#buttons

## References ##

* [Apple Developer Connection][apldev]
* [MacScripter][mcscrpt]
* [Mac OS X Hints][mcoshnt]

## EDITS ##

### r4 10-08-09 08:12 ###

I’ve removed the delays I once needed before each section. The modifier keys I was using (specifically ⌥) in my hot-key sequence were being passed to LittleSnapper and causing LittleSnapper to prompt me to choose a new image library. Taking ⌥ out of the sequence negated the need for the delays.

### r2 09-30-09 11:42 ###

While there is technically nothing wrong with the original script, the bash line — `do shell script “open -a LittleSnapper”` — throws an error in console and some part of that line looks as though it will not be supported for much longer. So I have changed this line to the slightly more verbose `tell application “LittleSnapper” to activate`

I have also split the 1 second delay into two 0.5 second sections, one at the front end and one before system events. It seems [FastScripts.app][fsa] really is fast and is getting ahead of itself when executing the script with hot-keys. That causes issues for me but may not affect you, depending on what you use to run your scripts.

[tags]applescript,automation,littlesnapper[/tags]

[ls]: http://www.realmacsoftware.com/littlesnapper/ “LittleSnapper – Screenshot and Website Capture for Mac OS X Leopard”

[em]: http://emberapp.com/seydoggy/ “View all images :: Ember”

[rssw]: http://www.red-sweater.com/ “Red Sweater – Amazing Mac Software”

[fsa]: http://www.red-sweater.com/forums/viewtopic.php?id=878 “How can I set keyboard shortcuts for FastScripts menus? (Page 1) – FastScripts – Red Sweater Software”

[lb]: http://www.obdev.at/products/launchbar/index.html “LaunchBar 5″

[qs]: http://code.google.com/p/blacktree-alchemy/ “blacktree-alchemy – Project Hosting on Google Code”

[btlr]: http://www.manytricks.com/butler/ “Many Tricks · Butler”

[ccdn]: http://www.codecollector.net/view/FCD7F708-8EB8-404D-B173-A8D2C6254B48

[apldev]: http://developer.apple.com/applescript/

[mcscrpt]: http://macscripter.net/

[mcoshnt]: http://www.macosxhints.com/search.php?query=applescript&mode=search&type=all&keyType=all

Comments (1) | Trackback
Powered by RapidWeaver, WP-Blog and WordPress 3.5.1