So here's a small example of how I managed to get the WindowID. It's pretty simple afterwards to take a screenshot using it. First you add a global monitor for events, more specifically NSMouseEvents. I used mouse down. The window information is stored in the mouse event.
CGWindowID windowID = (CGWindowID)[event windowNumber];
You can then take a screenshot of JUST the app, without shadows etc using the code below.
CGImageRef image = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, self.WindowID, kCGWindowImageBoundsIgnoreFraming);
Let me know if you need more.