How do I find the windowid to pass to screencapture -l? The command line utility screencapture claims to be able to capture a single window without requiring interaction, but I can't figure out what to pass it.

-l&lt;windowid&gt; capture this windowsid


It's not the process id of the the application.
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 developer.apple.com/downloads) if you run defaults write com.apple.QuartzDebug QuartzDebugPrivateInterface -bool true.