Block Screenshots of App?

Discussion in 'Mac Programming' started by ArtOfWarfare, Nov 14, 2012.

  1. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #1
    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.
     
  2. bumper314, Nov 14, 2012
    Last edited: Nov 14, 2012

    macrumors member

    Joined:
    Jun 23, 2009
    #2
    This used to work:

    [window setSharingType:NSWindowSharingNone];

    But it appears Apple broke something in 10.7.3, so it no longer prevents screenshots...
     
  3. ArtOfWarfare, Nov 14, 2012
    Last edited: Nov 14, 2012

    thread starter macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    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
     
  4. macrumors 6502a

    Joined:
    Jan 15, 2007
    #4
    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.
     
  5. macrumors newbie

    Joined:
    Jul 21, 2012
    #5
    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.
     
  6. macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #6
    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.
     
  7. ArtOfWarfare, Nov 16, 2012
    Last edited: Nov 16, 2012

    thread starter macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #7
    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.

    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.
     

Share This Page