Handle PrintScreen in C #

0

At one time a guy here in the forum helped me put together a program to take a picture of a specific window that I had opened on my computer. I wanted help to know if I can in this photo instead of being the whole window, just be a part of the window!

Question link: PrintScreen in C #

    
asked by anonymous 01.07.2017 / 01:49

1 answer

1

You will need 2 libraries:

using System.Drawing;  
using System.Drawing.Imaging; 

And to take the screenshot:

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); //Copia a imagem da tela
    printscreen.Save(@"C:\Temp\printscreen.jpg", ImageFormat.Jpeg); //Salva a captura de tela
}

Documentations: System.Drawing.Imaging and System.Drawing .     

01.07.2017 / 02:58