Scripting timed screenshots

I’ve known about the screencapture command for ages. My first screenshot/upload utility was written in Perl back in early 2006 and was invoked via Quicksilver. That early script gradually evolved into the snapftp script, written in Python and invoked via FastScripts, I use today. I learned yesterday that I haven’t been keeping up with screencapture’s improvements over the years. It now has an option for doing timed screenshots, which I’ve been using the venerable Grab application for. Using this option, I now have a smoother workflow for taking screenshots of menus and other ephemeral screen displays.

When I say screencapture “now has an option,” I’m using a very elastic definition of “now.” Looking back through the history of the screencapture man page, which you can do through the “Choose a version” popup menu, I’m embarrassed to say that it’s had this option since Leopard. Apparently, I haven’t checked the man page since I wrote that first script in 2006. Better late than never, I guess.

My timed screenshot script is barely a script at all:


screencapture -T10 -P ~/Desktop/snap.png

Just one line. The -T10 option tells it to take the screenshot 10 seconds after the script is called. I find that’s usually plenty of time to do whatever clicking or hovering is needed to bring up the item I want in the screenshot. The -P option tells it to open the screenshot file in Preview when it’s done. With a timed screenshot, screencapture takes a picture of the entire display, which is seldom what I want. By bringing it up in Preview right away, the script saves me the step of finding the file on the Desktop and opening it up for cropping.

You might think something this simple would be better defined as an alias in my .bashrc file than as a separate script. That’d be true if I called it from the Terminal, but I don’t. Calling a screenshot utility from the Terminal is clumsy, because you have to get the Terminal window out of the way before the screenshot is snapped. By saving it as a script, named “Timed Screenshot”, in my ~/Library/Scripts folder, I can call it via FastScripts with any application active. I’ve assigned it the ⌃⌥⌘3 keyboard shortcut, reminiscent of the builtin ⇧⌘3 full-screen capture shortcut.

Now it’s fast and easy to take screenshots like this

Menu screenshot

Although I’m kicking myself for wasting time with Grab for all those years, at least I won’t be wasting any more time with it.