take a photo to pc since a application c#? [closed]
I want to print all the screen with a button, and save it in any folder ( i know how to do it ) but i dont know how to take the photo ... and another thing, I want this program is HIDE and it works with a key for example f9 or f11 or any key, but i want this continue HIDE and worki开发者_Go百科ng, how to take the print pant? and how to work if it is hide?
thanks stackoverflow and partherns
You can use the below method to take the screenshot of a single window or the whole screen:
public void WindowsScreenshot()
{
// Full
Rectangle bounds = Screen.GetBounds(Point.Empty);
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
bitmap.Save("test_full.jpg", ImageFormat.Jpeg);
}
// Window
Rectangle bounds = this.Bounds;
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
}
bitmap.Save("test_window.jpg", ImageFormat.Jpeg);
}
}
精彩评论