Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 14, 2012, 07:06 PM   #1
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Block Screenshots of App?

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.
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old Nov 14, 2012, 07:56 PM   #2
bumper314
macrumors member
 
Join Date: Jun 2009
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 by bumper314; Nov 14, 2012 at 08:09 PM.
bumper314 is offline   0 Reply With Quote
Old Nov 14, 2012, 09:58 PM   #3
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by bumper314 View Post
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
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)

Last edited by ArtOfWarfare; Nov 14, 2012 at 10:35 PM.
ArtOfWarfare is offline   0 Reply With Quote
Old Nov 14, 2012, 11:55 PM   #4
foidulus
macrumors 6502a
 
Join Date: Jan 2007
Quote:
Originally Posted by ArtOfWarfare View Post
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 *)dataWithEPSInsideRectNSRect)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.
foidulus is offline   0 Reply With Quote
Old Nov 15, 2012, 03:13 AM   #5
1theo0
macrumors member
 
Join Date: Jul 2012
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.
__________________
MacBook White 4,1 2010 model
1theo0 is offline   0 Reply With Quote
Old Nov 15, 2012, 07:37 PM   #6
Sayer
macrumors 6502a
 
Sayer's Avatar
 
Join Date: Jan 2002
Location: 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.
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me
Sayer is offline   0 Reply With Quote
Old Nov 16, 2012, 11:16 PM   #7
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by Sayer View Post
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.

Quote:
Originally Posted by foidulus
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.
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)

Last edited by ArtOfWarfare; Nov 16, 2012 at 11:51 PM.
ArtOfWarfare is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
App to block all internet apart from safari iostraveller iOS 7 6 May 5, 2014 03:16 PM
iPad Mini: Lag when clicking on App screenshots? itismadhan iPad 0 Nov 19, 2013 12:15 PM
Will block app cellular usage also block wi-fi? Snesley Wipes iOS 7 4 Sep 19, 2013 09:03 AM
any free app to block contact Hpye iOS 6 6 Oct 31, 2012 07:14 PM
Tracking which app is taking screenshots ebt Mac Basics and Help 0 Jul 17, 2012 05:03 AM

Forum Jump

All times are GMT -5. The time now is 03:22 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC