Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,560
6,059
I'm making a freemium art program for the Mac. One of the pay for features is being allowed to export the file in a non-propietary format. If people were allowed to take screenshots of the canvas in the free version, that'd obviously reduce the number of people willing to pay for the full version.

So, does anyone know how I can make a sandboxed app that will distort or block screenshots of its canvas?

I'm okay with a non-bulletproof solution, I just want something that reduces the number of people who are content with working around it.
 

bumper314

macrumors member
Jun 23, 2009
39
0
This used to work:

[window setSharingType:NSWindowSharingNone];

But it appears Apple broke something in 10.7.3, so it no longer prevents screenshots...
 
Last edited:

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,560
6,059
This used to work:

[window setSharingType:NSWindowSharingNone];

But it appears Apple broke something in 10.7.3, so it no longer prevents screenshots...

That's unfortunate... blocking grab and preview screen captures wouldn't be too difficult, I'd just mask the art whenever the app loses focus, but I can't think of anything similar that I could do to... unless... can I disable keyboard shortcuts while my app has focus? Or maybe just detect when the keyboard shortcut is pressed and mask the image?

Edit:
:-/ I made a simple test app where all I had was a subclass of an NSWindow that immediately returned on keyDown, but it didn't do anything to block screen captures... it didn't even notice when the proper keys were pressed.

2X Edit:
Tried to assign command-shift-4 to the About App menu item instead, it still completely failed to block screenshots...

3X Edit:
Tried the code you suggested even though you said it didn't work. It actually blocks command-shift-4-space (window capture) and displays a message saying the window can't be captured, but it doesn't block command-shift-4 (selection capture) - even if the selected area includes the window.

Giving up for now... I'm interested in hearing if anyone has any other suggestions for how to either:
1 - intercept attempts to take screenshots entirely or
2 - know that a screenshot is being taken and black out the window briefly to avoid having it included
 
Last edited:

foidulus

macrumors 6502a
Jan 15, 2007
904
1
That's unfortunate... blocking grab and preview screen captures wouldn't be too difficult, I'd just mask the art whenever the app loses focus, but I can't think of anything similar that I could do to... unless... can I disable keyboard shortcuts while my app has focus? Or maybe just detect when the keyboard shortcut is pressed and mask the image?

Edit:
:-/ I made a simple test app where all I had was a subclass of an NSWindow that immediately returned on keyDown, but it didn't do anything to block screen captures... it didn't even notice when the proper keys were pressed.

2X Edit:
Tried to assign command-shift-4 to the About App menu item instead, it still completely failed to block screenshots...

3X Edit:
Tried the code you suggested even though you said it didn't work. It actually blocks command-shift-4-space (window capture) and displays a message saying the window can't be captured, but it doesn't block command-shift-4 (selection capture) - even if the selected area includes the window.

Giving up for now... I'm interested in hearing if anyone has any other suggestions for how to either:
1 - intercept attempts to take screenshots entirely or
2 - know that a screenshot is being taken and black out the window briefly to avoid having it included

Well it's definitely possible(certainly if you are willing to drop down into the "private APIs"), look at iTunes. You cannot capture part of the screen when a (iTunes store?) video is playing, all you get is a checkerboard...

Just briefing through the NSWindow/NSView docs, it looks like you might be able to override a couple of methods to do this, but I am not sure what else they may effect, so you will have to experiment:

dataWithEPSInsideRect:
Returns EPS data that draws the region of the receiver within a specified rectangle.

- (NSData *)dataWithEPSInsideRect:(NSRect)aRect
Parameters
aRect
A rectangle defining the region.
Discussion
This data can be placed on an NSPasteboard object, written to a file, or used to create an NSImage object.

Availability
Available in OS X v10.0 and later.
See Also
– writeEPSInsideRect:toPasteboard:
Declared In
NSView.h

So you would have to create a custom class that extends NSWindow then if premium return the super class's method, if not return nil.
 

1theo0

macrumors member
Jul 21, 2012
32
0
I don't code apps, but I know that the DVD player window is blank when doing screenshots- maybe there's a way to explore its code and find out how to blank out your windows as well. Good luck.
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Put a watermark over the canvas. Obviously on export/save don't 'flatten' the watermark layer on top, and don't remove the watermark layer until it's a paid app.
 

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,560
6,059
Put a watermark over the canvas. Obviously on export/save don't 'flatten' the watermark layer on top, and don't remove the watermark layer until it's a paid app.

I have considered that possibility, but I despise watermarks and companies that use them. I want my users to be able to view and appreciate their creations, they just shouldn't be able to share it outside of my app without paying.

foidulus said:
Well it's definitely possible(certainly if you are willing to drop down into the "private APIs"), look at iTunes. You cannot capture part of the screen when a (iTunes store?) video is playing, all you get is a checkerboard...

I was hoping to have the app be a free download in the Mac App Store and then use IAP to unlock the full app - but I don't think Apple allows private APIs on the MAS.

I suppose I could just put a paid, unlocked, full version of the app on the MAS and then offer a free, uses private APIs to ensure you don't share, version of the app through my website... not sure if my web host would allow that or that Apple would be thrilled with me mentioning it in the app description on their store.

---

:-/ Experimented with foidulus's method suggestion, but the system never seems to call that?

Blocking various other apps from taking screenshots is pretty easy... as soon as the app loses focus, block the window... heck, it even blocks screenshots from the terminal command, because that involves switching to the terminal application (although it doesn't block Grab > Timed Screen Shot, if the user then clicks back on the window,) but I can't for the life of me come up with how to block users from just using the keyboard shortcuts...

I tried using various TrackingRect methods but as soon as the user hits command-shift-4, it stops sending any updates until they either take a picture or hit escape.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.