Can I prevent a user from taking screenshots in a

2020-02-26 01:47发布

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)

标签: cocoa macos
5条回答
欢心
2楼-- · 2020-02-26 02:27

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?

查看更多
家丑人穷心不美
3楼-- · 2020-02-26 02:34

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.
查看更多
做自己的国王
4楼-- · 2020-02-26 02:39

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

查看更多
5楼-- · 2020-02-26 02:42

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.

查看更多
霸刀☆藐视天下
6楼-- · 2020-02-26 02:45

No; that's a system feature.

查看更多
登录 后发表回答