Apple - How do I find the windowid to pass to screencapture -l?

For some applications you can use AppleScript:

screencapture -l$(osascript -e 'tell app "Safari" to id of window 1') test.png

It doesn't work with Chrome though.

The IDs are also shown in Quartz Debug (available from if you run defaults write QuartzDebugPrivateInterface -bool true.

I wrote a little command line utility to retrieve the Window ID for apps that don't support AppleScript. Get it here:

You can then capture a specific window by specifying its bundle name and window title:

screencapture -l$(./GetWindowID "Vuo Editor" "untitled composition") VuoEditorWindow.png

I wrote a command line utility that wraps over screencapture and the Quartz windowing library.

Grab it here:

Use it like this:

screenshot Chrome -t "Stack Overflow"