How to capture screen in screen saver mode (c#)?

201 views Asked by At

I created an application that captures the current screen and uses it as the background image of the form. The application works normally within Visual Studio, also when I run it bycompiled exe and also when the exe is renamed to scr. However when I install the scr file as is my default screen saver (File Context Menu -> Install), the captured screen is always the desktop, never the windows that are active in the foreground.

   private void Form1_Load(object sender, EventArgs e)
    {
        this.Location = new System.Drawing.Point(0, 0);
        this.Size = new System.Drawing.Size(3200, 900);

        var tela = new Bitmap(3200, 900, PixelFormat.Format32bppArgb);
        var imagem = Graphics.FromImage(tela);

        imagem.CopyFromScreen(0, 0, 0, 0, this.Size,
                                    CopyPixelOperation.SourceCopy);

        tela.Save("tela.png", ImageFormat.Png);

        this.BackgroundImage = new Bitmap("tela.png");
    }
0

There are 0 answers