Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
1  
Unfortunately, this doesn't work with non-Applescriptable apps like Eclipse or Google Chrome. – CajunLuke Jul 16 '12 at 18:52
Yeah, my target app is not Applescriptable :( But thank you anyway. – Gareth Simpson Jul 16 '12 at 19:13
1  
Note that window ids are not guaranteed to correspond to the Quartz window id even in applications that are scriptable. – Chris Page Aug 11 '12 at 5:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.