views:

212

answers:

3

I need to be able to identify a single window on the user's screen and take a screen capture of it. The screen data is to be stored in memory and not written to disk.

This is already supported through the commandline tool /usr/sbin/screencapture or through the Grab utility (though their functionality is not extensive enough to justify me launching them as a subprocess).

References / Hints

  • nm /usr/sbin/screencapture returns private Cocoa interfaces including _CGSGetSharedWindow that appear to do this.
  • Third party application Snapzpro does this (but does not provide source code)
A: 

Command+Shift+4 to activate the screenshot selection, then tap the space bar to select the whole window.

redwall_hp
+5  A: 

Mac OS X 10.5 introduced the Quartz Window Services API to do just this.

Chuck
This does the trick. A short Google provided sample code, rigged with profiling. http://developer.apple.com/samplecode/SonOfGrab/index.html
sludge
A: 

The first thing that came to mind was GrabFS from MacFuse. The source is here.