9

I have an image application and I want to release it where unregistered users can view the files but cant save until they've registered.

I'm looking for a way to prevent the user from using the built in screenshot functionality so I don't have to watermark the images. How might I accomplish this?

-- Edit Below --

I decided to watermark the images. I had been trying to avoid watermarking since the images are stereoscopic but I'm rather happy about how the watermark looks now. I put a logo in the corner and offset it enough on each image so it appears in the foreground.

Whether people agree with it in practice or not, my question is still valid. Apple's DVD Player hides the video in its screenshots, which doesn't altogether stop the user from taking screenshots but accomplishes my original goal.

I would still very much like to know how to do this. (the DVD player way)

ЯegDwight
  • 24,821
  • 10
  • 45
  • 52
rennat
  • 2,529
  • 3
  • 26
  • 30
  • 1
    You could stand behind them and grab their hand when the tried to press the screenshot keystroke! – nate c Nov 21 '10 at 21:27
  • 1
    DVD player is using a hardware video overlay. Not sure what the API to do that on Mac OS X is, but even then the dastardly user could take out their camera and take a picture :-P Your watermark is probably a better solution, just make sure it isn't easy to crop it off. – derobert Mar 15 '11 at 17:03

5 Answers5

9

Based on a symbols search through DVD Player, it likely uses the private API CGSSetWindowCaptureExcludeShape. Richard Heard has been kind enough to reverse engineer it and wrap it for easy use.

Being private, it may stop working (or have already stopped working) at any time.

But ultimately the answer to your question is "yes, but not in any publicly documented way". Some other takeaways from this lengthy thread are:

  1. Asking this question inevitably excites a lot of myopic moral outrage.
  2. Given there's no public method, reverse engineering DVD Player is a useful path to pursue.
  3. A request to Apple DTS might be the only reliable method to find an answer.
Heath Raftery
  • 3,643
  • 17
  • 34
3

One option that is very user hostile is to change the folder in which screen captures are stored to a /dev/null style directory by changing the com.apple.screencapture setting.

A huge downside of this is that you might mess up the users settings and not being able to restore them if the exit from your application isn't clean.


Another option is to keep track of what files that are created in the screen capture location, see if they match the pattern for name and then remove them.

This method is still quite hostile though.


I also investigated if it was possibility to kill the process that handle the screen capture, unfortunately the process that handles it, SystemUIServer just reboots after being killed.


SystemUIServer seems to refuse taking screenshots if DVD Player currently is playing a DVD. I have no idea how the DVD playback detection works though, but it might be a lead to prevent screenshots.


Links


Disclaimer before people start ranting: I have a legit reason to solve this problem, but won't use the com.apple.screencapture -> /dev/null method due to it's downsides.

JWWalker
  • 22,385
  • 6
  • 55
  • 76
Robin Andersson
  • 5,150
  • 3
  • 25
  • 44
3

DVD Player does this (the user can still take the screenshot, but the player window doesn't appear in it), so I'm sure there's a way. Maybe setting the window's sharing type to NSWindowSharingNone?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • 4
    The video is probably implemented as an overlay. In effect, it isn't really there in the active display buffer, but gets merged in on the way out to the cable. – Chris Stratton Nov 23 '10 at 18:19
  • Putting this question to rest even tho it was never really answered. This is the best answer out of those received. – rennat Aug 29 '11 at 18:03
  • @ChrisStratton - How might we accomplish the same thing in our apps? – ArtOfWarfare Nov 17 '12 at 05:33
  • @ArtOfWarfare please do not. – Chris Stratton Nov 17 '12 at 17:35
  • 2
    @ChrisStratton - Between having a watermark on screen until my user pays or simply blocking them from taking screenshots, I'm pretty sure they'd much rather I didn't have a watermark permanently in place. I'm not about to invest my free time for the next several months in an app that my users are never going to pay for - I have $40K worth of student bills to pay off (and I'm still in school.) If you know how to do what DVD Player does, could you please let us know? – ArtOfWarfare Nov 19 '12 at 13:36
  • 3
    @ArtOfWarfare please do not waste your time or your user's patience implementing negative features which are trivially defeated and only encourage the distribution of more user-friendly, pirated, versions of programs. – Chris Stratton Nov 19 '12 at 15:27
  • @ChrisStratton - The app is free with IAP - users wouldn't bother pirating it because all they'd end up with is the same thing as they could get for free without going through the effort of pirating. I'm okay with the hacker sort of user finding it trivial to defeat; I expect my users mostly won't know how to get around it and would happily pay the $4 or $5 fee. I'm making a drawing app - I figure users get everything but exporting to a common format for free. Do you or don't you know how to do what DVD Player does, and could you let us know if you do? – ArtOfWarfare Nov 19 '12 at 19:30
  • 3
    Do not do this. It's not a technology problem, but a usability one. If the benefits of working around your proposed restriction are as minor as you claim, then it's not worth the trouble and usability hit of trying to implement said restriction. – Chris Stratton Nov 20 '12 at 03:42
  • @Peter Hosey The link has been updated. Could you please update the link to `https://developer.apple.com/documentation/appkit/nswindowsharingtype/nswindowsharingnone?language=objc` – bikram990 Jun 30 '17 at 10:14
  • `NSWindowSharingNone` is not effective against the screen capture hotkeys (and only partially effective against screen capture applications) and is not the way DVD Player does it. Lest this become a Q&MRI site (Question and My Righteous Ideology) see my attempt at answering the question asked. – Heath Raftery Jan 30 '18 at 12:27
2

You could try to run your application fullscreen and then capture all the keystrokes. But please listen to siride.

Martijn
  • 586
  • 5
  • 19
  • 1
    I have tried this. It does not work. I set up an app to capture all keystrokes, and it was able to catch all of them except the ones for taking screenshots. – ArtOfWarfare Nov 17 '12 at 05:34
-4

No; that's a system feature.

DarkMalloc
  • 319
  • 2
  • 9