~robcee/ more than just sandwiches

Posted
10 February 2009 @ 11am

Tagged
Code, Mozilla

Automated Screen Grab and Upload Howto

If you’ve been around these parts, you may have seen a flurry of screencaps with the words “Grabup” on/in/around them. Tired of the constant advertisements, I decided to roll my own.

(before proceeding, I should tell you that Johnath has a shell script you can invoke from a terminal window that you might find adequate. The setup is certainly less annoying, but then you’ll have to type something on the command line everytime you want it, and that’s hardly intuitive, nice and it does a funny thing with character-encodings in the filename (edit: this was zsh making the filename look funny, oops, sorry J))

What you’ll need:

  • Mac OS X 10.5 (you might get away with 10.4)
  • Some kind of web-enabled remote storage (I’m using “people.mozilla.org”, but if you’ve got MobileMe you could do this with an iDisk or some other WebDAV-enabled system)
  • MacFUSE + SSHFS
  • FastScripts Lite
  • Grabup-window-template workflow.

The latter two may have alternatives. I’m using FastScripts lite (thanks for the tip, neilio!) to bind a hot-key to the Automator script, but you could do the same with Quicksilver and probable several other tools. SSHFS is alternatively available in MacPorts, but I like the Google Code supplied version for the handy installer.

The Setup:

First, setup your “web-drive” through MacFUSE. Be sure to install the latest SSHFS binary. Read the instructions. I have mine setup as aliases I can run from the Terminal. E.g.,

mountpeople=’sshfs people:/home/rcampbell/ ~/Volumes/people -oreconnect,volname=people’

Next, you will need to edit the Automator action. Start Automator and select the Open Existing Workflow button.

Open the Grabup-window-template file (extracting it first from the zip file), and change the entries below. I am going to recommend here that you create a throw-away screenshot and put it in a Screenshots subdirectory under Pictures. Name the image “pic.png” or similar. You’re going to need to select something as a filename in Automator’s first action (Take Screenshot). Ridiculous, I know, but here we are.
grabup-window

Next, select your destination in the “Copy Finder Items” action. You’ll want to make sure your remote drive is mounted. If you’re using MacFUSE, drag the drive from your desktop into the sidebar of the Finder so it shows up in the open dialog, alternatively, you can just drag the drive from your desktop onto the open file dialog and you should be able to browse it from there. I have a public_html/screenshots directory, and have selected that.

In the last action you have the option of opening the screenshots directory in your browser. The Run Shell Script action just calls the “open” command which will open a URL of your choosing. If you can do this all by yourself, feel free to delete the action entirely. I give you permission!

When you’re happy, save the automator action as a Workflow in your home directory’s Library/Scripts folder and give it a snappy name. I call mine “Grabup-window”. If FastScripts (lite) is running, it will show up in that menu. Now you can open FastScripts’ Preferences window and give Grabup-window a hotkey. I chose Cmd-Shift-5.

Now, whenever I hit that hotkey, I’m promted to select a window and a screenshot is automatically uploaded to my directory. No more tears. I hope this is useful and not nearly as painful as it has been to describe here.

note, as there are only 86400 seconds in a day, eventually, you will get collisions. You can pick a different rename pattern to make your images last longer, or change the option to overwrite automatically. It’s up to you. YOU HAVE THE POWER!

Update: added an extra entry to the Grabup-window-template file so it now adds today’s date to the beginning of the filename. No more collisions.


1 Comment

[...] February I posted a write-up on how to automate uploads of screen captures to a web directory for sharing with others. The idea [...]