Scripting LittleSnapper

Scripting LittleSnapperI 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 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 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*:

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 FastScripts.app. You could also use this in LaunchBar, QuickSilver, Butler, or any other means you may use to run AppleScripts.

Full Script

-- This script launches LittleSnapper
-- <http://realmacsoftware.com/littlesnapper/>
-- and tells it to snap the current web page

-- By Adam Merrifield <http://www.seydoggy.com>
-- 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

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.

References

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 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]

 

Adam Merrifield

 

One thought on “Scripting LittleSnapper

Leave a Reply