How do I take a screengrab of a single window using Cocoa or Carbon on OS X? [closed]
-
23-08-2019 - |
Question
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)
Solution
Mac OS X 10.5 introduced the Quartz Window Services API to do just this.
OTHER TIPS
The first thing that came to mind was GrabFS from MacFuse. The source is here.
Command+Shift+4 to activate the screenshot selection, then tap the space bar to select the whole window.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow