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<windowid> capture this windowsid
It's not the process id of the the application.
For some applications you can use AppleScript:
It doesn't work with Chrome though.
The IDs are also shown in Quartz Debug (available from developer.apple.com/downloads) if you run
I wrote a little command line utility to retrieve the Window ID for apps that don't support AppleScript. Get it here: https://github.com/smokris/GetWindowID
You can then capture a specific window by specifying its bundle name and window title:
I wrote a command line utility that wraps over
Grab it here: https://github.com/thismachinechills/pyscreencapture
Use it like this: