I am trying to find the answer to a topic which has basically driven me insane. Is there a way to capture the mouse pointer much like Apple's screencapture utility works? What I am trying to do requires me to draw a clear window that does not activate my app but instead overlays everything, including the dock. The only software I have seen do this is screencapture by utilizing command+shift+4.
I have tried creating a non-activating NSPanel but it doesn't work with cursor rects unless my app is active (which I don't want it to be). Also the problem with NSPanel is that if I am in Dashboard I cannot activate the window on it.
The requirements for what I am trying to do are this. • My app must not activate (keep whatever active app as active) • Must be able to change NSCursor • Mouse does not trigger dock hiding/unhiding (or any other event) • Work even in dashboard
I have tried this code before but its limitations are the same as listed above.
NSScreen * s = [NSScreen mainScreen];
[self.window setStyleMask:NSNonactivatingPanelMask];
[self.window setHasShadow:NO];
[self.window setOpaque:NO];
[self.window setBackgroundColor:[NSColor clearColor]];
[self.window setFrame:s.frame display:NO];
[self.window orderFront:self];
[self.window setLevel:NSMainMenuWindowLevel + 1];
[self.trackingView addCursorRect:self.window.frame cursor:[NSCursor closedHandCursor]];