简体   繁体   English

检测用户何时截取我的程序的屏幕截图

[英]Detect when users take screenshots of my program

I'm writing a Windows application. 我正在写一个Windows应用程序。 How can I tell when a screenshot is being taken of it? 如何判断屏幕截图是什么时候? I read about how to detect the hotkey being pressed, but I'm more worried about the case where every 100 ms or so another program is taking screenshots of it. 我读到了如何检测被按下的热键,但是我更担心每100毫秒左右另一个程序正在截取它的截图。 Namely, I'm trying to notice when someone creates another program (say a python one using ImageGrab, as mentioned in another post) which constantly takes screenshots of my app and uses them to read info off of it. 也就是说,我试图注意到有人创建了另一个程序(比如使用ImageGrab的python,如另一篇文章中提到的),它不断截取我的应用程序的截图并使用它们来读取信息。

I don't care much about preventing the screenshots from being taken - I can just ban the user once this behavior is noticed. 我不太关心阻止屏幕截图被采取 - 一旦注意到这种行为,我就可以禁止用户。

Is this possible? 这可能吗? Is there a windows message sent when any app takes a screenshot, like with WM_HOTKEY? 当任何应用程序截取屏幕截图时是否会发送Windows消息,例如WM_HOTKEY? Or does windows just use the latest info from the latest paint events, and return that to the other program directly, without my app being able to notice at all? 或者Windows是否仅使用最新绘制事件中的最新信息,并将其直接返回到其他程序,而我的应用程序根本无法注意到?

Whatever you do, people will find a way around it. 无论你做什么,人们都会找到解决办法。 Suppose such a method existed, where you could reliably detect another program taking a screenshot of your application. 假设存在这样一种方法,您可以可靠地检测另一个程序,截取您的应用程序的屏幕截图。 To get around that, I could install VirtualBox, run your application inside the VM, and then have a program take screenshots of VirtualBox (which then contains your application). 为了解决这个问题,我可以安装VirtualBox,在VM中运行你的应用程序,然后让程序获取VirtualBox的截图(然后包含你的应用程序)。 Your application would have absolutely no way to know it was having its picture taken. 你的申请绝对没有办法知道它拍了照片。

What if I use a video camera? 如果我使用摄像机怎么办? What if I capture the video coming between the computer and the monitor? 如果我捕获计算机和显示器之间的视频怎么办?

I'll be surprised to learn there's any practical way to do this. 我会惊讶地发现有任何实用的方法可以做到这一点。

This is never going to work. 这永远不会奏效。 Not only that, but attempts to provide this level of security are going to inconvenience 99% of your legitimate users. 不仅如此,但提供此级别安全性的尝试将使99%的合法用户感到不便。

You perhaps are best to approach the problem from the angle of trying to identify unwanted uses/copies of your information and approach the people/companies using that information. 您可能最好从尝试识别信息的不需要的使用/副本的角度处理问题,并使用该信息与人/公司联系。

Copyright law is appropriate for this approach, but I understand that there are some intances where this approach is not available. 版权法适用于这种方法,但我理解有些方法无法使用这种方法。

You can (unreliably) do this by using SetWindowsHookEx . 您可以(不可靠)使用SetWindowsHookEx执行此操作。

Here is a complete VB.NET example. 这是一个完整的VB.NET示例。

However, there are many ways around this. 但是,有很多方法可以解决这个问题。 A hook installed after yours will "override" your hook. 你的安装后的钩子将“覆盖”你的钩子。 Users can take pictures of their screen in many ways, as described in this thread. 用户可以通过多种方式拍摄屏幕图片,如本主题所述。 I'd try to consider other options for protection than this. 我会尝试考虑其他保护选项。

First, comments about using a virtual machine are completely pointless -- it is much easier to detect windows running under a virtualizer than to detect a screenshot being taken. 首先,关于使用虚拟机的评论完全没有意义 - 检测在虚拟器下运行的窗口比检测正在拍摄的屏幕截图要容易得多。

A good way to make screenshots difficult would be to rewrite your program to run in full screen mode under some ancestral dos extender. 使截图很难的一个好方法是重写你的程序,在一些祖先的dos扩展器下​​以全屏模式运行。

A good way to ban 95% of users who ever attempted to take a screenshot is to display a huge flashing banner on startup ("screenshots prohibited! you be banned!"), and detect user pressing PrtScrn during the following 15 seconds. 禁止95%尝试截屏的用户的一个好方法是在启动时显示一个巨大的闪烁横幅(“截图禁止!你被禁止!”),并检测用户在接下来的15秒内按下PrtScrn。

完全阻止它是非常困难的...一个足够坚定的用户可以用数码相机拍摄一张屏幕照片。

Another reason why I think it will be impossible to achieve this: 我认为无法实现这一目标的另一个原因是:

A long time ago, I failed to make a screen capture of the content of Windows Media Player, because (I assumed) WMP streamed that content to the videocard right away. 很久以前,我没有对Windows Media Player的内容进行屏幕截图,因为(我假设)WMP会立即将该内容流式传输到视频卡。 (Fun detail: after pasting the screen capture, the video would continue playing in MS Paint, but saving the image would eventually yield a black square). (有趣的细节:粘贴屏幕截图后,视频将继续在MS Paint中播放,但保存图像最终会产生黑色方块)。 Anyway, using VNC made it very easy to get the screen capture after all. 无论如何,使用VNC使得终端屏幕捕获变得非常容易。

The way I usually take screenshots (from C#) is by calling BitBlt, which is the basis of a lot of screen painting. 我通常采用截图(来自C#)的方式是调用BitBlt,这是很多屏幕绘画的基础。 Not sure how you'd intercept calls to it in any meaningful way, since probably every program on the system uses it at a low level. 不确定如何以任何有意义的方式拦截对它的调用,因为系统上的每个程序都可能在较低级别使用它。

I assume you really can't because one can always run your program in a window with virtual machine, then using a capture program on the outside platform, and knowing if this is happaning is mighty difficult. 我假设你真的不能,因为一个人总是可以在一个带有虚拟机的窗口中运行你的程序,然后在外部平​​台上使用一个捕获程序,并且知道这是否是非常困难的。 I suggest thinking more in ways of special rendering pace or interlacing, special contrasts, etc... 我建议更多地考虑特殊渲染速度或隔行扫描,特殊对比等...

You can also run your outputs to the screen as if it was a movie, encode it with a low rate and resolution encoder, so that a still capture every 100ms will be in such a low quality that it would be worthless. 您还可以将输出运行到屏幕,就好像它是一部电影一样,使用低速率和分辨率编码器对其进行编码,这样每100毫秒仍然捕获的质量将会非常低,以至于它将毫无价值。 (have you ever freezed a low quality movie?) (你有没有冻过低质量的电影?)

however you really should consider using other ways to protect your info. 但是你真的应该考虑使用其他方法来保护你的信息。

there is one way that i think might stop it. 我认为有一种方法可以阻止它。 learn about the technology that blurs a graphical display when it is duplicated for example. 了解在复制时模糊图形显示的技术。

screenshot, photographed by digital camera screenshot from virtual os. 截图,由虚拟操作系统截图的数码相机截图。

play with it , who knows you might invent something that will make u millions. 玩它,谁知道你可能发明一些会让你成千上万的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM