Taking screenshot programmatically in mac only for application window
Simple.
NSImage *captureImage = [[NSImage alloc] initWithData:[self.view dataWithPDFInsideRect:[self.view bounds]]];
please check and let me know. This is captured current active window.
To actually take a screenshot of your window, including its frame and shadow, get your window's windowNumber
and pass that to the CGWindowListCreateImage
function.