2

So I was wondering if there is a way to prevent a program from taking screenshots or allowing a program to take screenshots but blackened to image.

Program that takes screen shot is as follows:

using System.Drawing.Imaging;
namespace ScreenCapture
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {}

        private void PrintScreen()
        {

            Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

            Graphics graphics = Graphics.FromImage(printscreen as Image);

            graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);

            printscreen.Save(@"C:\Temp\printscreen.jpg", ImageFormat.Jpeg);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            PrintScreen();
        }
    }
}

If I handle PrintScr returning null would it work?

P.S. : Its not like I want to prevent a program from having its screenshot taken, I want to prevent program from taking screen shots of the complete desktop screen

Basically, I have a program that is taking screenshots every min,i.e., monitor the user's activity. I want a create a program to nullify it. NOT STOP THE PROGRAM

6119
  • 99
  • 8
  • `Process.GetProcessByName("ScreenCapture.exe").First().Kill()` – dcastro Jan 20 '15 at 14:47
  • 1
    http://stackoverflow.com/questions/22072329/how-to-intercept-each-trying-to-use-api-function-in-c – Giorgi Nakeuri Jan 20 '15 at 14:52
  • Related: http://stackoverflow.com/questions/6554018/how-to-prevent-screenshot-from-program – default Jan 20 '15 at 14:52
  • @dcastro I dont want to kill the program. – 6119 Jan 20 '15 at 15:18
  • You could try setting the TransparentKey property of the form you want to hide to anything other than `null`. There are probably ways around this and it's probably a side effect rather than designed, but it's worth a try and works for the simple screen capture example you shown above. Otherwise, se if the UIPermission class can offer anything. – Evil Dog Pie Jan 20 '15 at 15:20
  • You could also look into [SetWindowDisplayAffinity](http://msdn.microsoft.com/en-gb/library/windows/desktop/dd375340(v=vs.85).aspx). I think you'd need to pinvoke it from c#, but that shouldn't be a problem. – Evil Dog Pie Jan 20 '15 at 15:29
  • There's also a bunch of [anti key logging](https://www.raymond.cc/blog/what-is-the-best-anti-keylogger-and-anti-screen-capture-software/) software that will do it. – Evil Dog Pie Jan 20 '15 at 15:42
  • @MikeofSST Many thanks.... SetWindowDisplayAffinity is exactly what I was looking for....But it works for the program in which I have code it how would I apply it on the whole desktop screen? – 6119 Jan 20 '15 at 15:48
  • I don't know if you can - I expect you'll get a permission exception if you try to set it on the desktop. I've only ever used it on my own applications. – Evil Dog Pie Jan 20 '15 at 16:02
  • @MikeofSST I see,.....d(^ ^) – 6119 Jan 20 '15 at 16:09
  • @MikeofSST Just a thought,....What if I create a transparent form that runs foreground always but does register input....kinda like AVS Screen Capture? – 6119 Jan 20 '15 at 17:19

0 Answers0