简体   繁体   English

WinForm C#:如何防止截图工具或截图和草图工具捕获特定孩子 window 的屏幕截图?

[英]WinForm C# : How to prevent Snipping tool or Snip & Sketch tool to capture screen shot of the particular child window?

I would like to prevent capturing screen using snipping tools.我想防止使用截图工具捕获屏幕。 I've already prevented Print Screen by registering KeyUp event and clearing clipboard.我已经通过注册 KeyUp 事件和清除剪贴板来阻止 Print Screen。 I would like to prevent capturing screen only for particular Child Form (Popup Dialog).我想阻止仅为特定子表单(弹出对话框)捕获屏幕。

I tried Form Deactivate event but as soon as user click on Snipping tool's New Snip function, it activates my application.我尝试了 Form Deactivate 事件,但是一旦用户单击 Snipping 工具的 New Snip function,它就会激活我的应用程序。

Edit编辑

I found a gimmick.我发现了一个噱头。 Please note that neither it's bulletproof solution nor its good User Experience but it might be helpful for some of you out there.请注意,它既不是防弹解决方案,也不是良好的用户体验,但它可能对你们中的一些人有所帮助。

Steps脚步

  1. Take panel, set background color property to gray (or any of your choice).采取面板,将背景颜色属性设置为灰色(或您选择的任何一种)。
  2. Make sure that panel is hidden and it's SendToBack.确保该面板是隐藏的,它是 SendToBack。
  3. Register panel's click event.注册面板的点击事件。
  4. Register Form Deactivate event.注册表格停用事件。
  5. On Form Deactivate, set that panel's visibility to true, dock it to fill screen and set BringToFront.在 Form Deactivate 上,将该面板的可见性设置为 true,将其停靠以填满屏幕并设置 BringToFront。 So when user switch to other application or click anywhere outside the app, grayed out panel will cover your actual screen.因此,当用户切换到其他应用程序或单击应用程序外的任何位置时,灰色面板将覆盖您的实际屏幕。
  6. When user switch back to the application, make them click on panel to reopen (unhide) your actual screen.当用户切换回应用程序时,让他们单击面板以重新打开(取消隐藏)您的实际屏幕。

Again, as I said this is gimmick and not good User Experience but it might help someone like me whose main objective is to prevent users from taking screen shot of sensitive data.同样,正如我所说,这是噱头,不是很好的用户体验,但它可能会帮助像我这样的主要目标是防止用户截取敏感数据的人。

User can still take picture using their phone or camera or screenshot VM by running your application in VM.用户仍然可以通过在 VM 中运行您的应用程序来使用他们的手机或相机或截图 VM 拍照。 So my solution is not bulletproof but at least it will definitely make it not so easy.所以我的解决方案不是万无一失的,但至少它肯定会让它变得不那么容易。

Cheers!!干杯!!

Use pInvoke to call SetWindowDisplayAffinity(hwnd, WDA_MONITOR);使用 pInvoke 调用SetWindowDisplayAffinity(hwnd, WDA_MONITOR);

From Old New thing旧新事物

That said, the customer could modify their proprietary program to call the SetWindowDisplayAffinity function to indicate that the window contents should not be included in screen captures, as I noted some time ago.也就是说,客户可以修改其专有程序以调用 SetWindowDisplayAffinity function 以指示 window 内容不应包含在屏幕截图中,正如我前段时间所指出的那样。 The desktop compositor will prevent those pixels from being included in BitBlt and other screen capture functions.桌面合成器将阻止这些像素包含在 BitBlt 和其他屏幕捕获功能中。

UWP applications can set the ApplicationView.IsScreenCaptureEnabled property to false to exclude a view from screen capture functions. UWP 应用程序可以将ApplicationView.IsScreenCaptureEnabled属性设置为 false 以从屏幕捕获功能中排除视图。

That said, this only makes it slightly more difficult to capture data.也就是说,这只会使捕获数据变得更加困难。 There are ways around it, and whatever you do, you cannot prevent anyone from whipping out a mobile phone and taking a picture, or just writing down the important parts to a notepad.有办法绕过它,无论你做什么,你都无法阻止任何人拿出手机拍照,或者只是将重要的部分写到记事本上。

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

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