How would I save my active window as an image whether it be a gif, jpg, etc...? I know how to send keys for the Alt & Print Screen but then how do I take that and save that image? Thanks.
Printable View
How would I save my active window as an image whether it be a gif, jpg, etc...? I know how to send keys for the Alt & Print Screen but then how do I take that and save that image? Thanks.
Here you go :
PHP Code:private Image GetScreenCapture(bool FullScreen)
{
if (FullScreen)SendKeys.SendWait("{PRTSC 2}");
else SendKeys.SendWait("%{PRTSC}");
IDataObject objData=Clipboard.GetDataObject();
return (Image)objData.GetData(DataFormats.Bitmap);
}
private void button1_Click(object sender, System.EventArgs e)
{
//Take shot !
GetScreenCapture(true).Save(@"c:\test.bmp");
pictureBox1.Image = GetScreenCapture(true);
}
Thanks for the code, the only thing is that when I go to open test.bmp it says it is not a valid file. It put the screen shot in the picture box but the file is not valid. Any ideas??
Here is the exact message.
Replace the old line with this one(and specifiy the format you want to save the image to :
PHP Code://Take shot !
GetScreenCapture(true).Save(@"c:\test.bmp",ImageFormat.Bmp);
Thanks again Pirate!!
Glad to help.;)