0

How do I make a screenshot programmatically in c# from several operating systems?

I have a application running on several systems. Mac Linux and Windows 7.

Cœur
  • 37,241
  • 25
  • 195
  • 267
ProggerJoe
  • 97
  • 9

2 Answers2

1

for Windows,

ScreenCapture sc = new ScreenCapture();
Image img = sc.CaptureScreen();
this.imageDisplay.Image = img;
sc.CaptureWindowToFile(this.Handle,"D:\\ScreenShot1.png",ImageFormat.png);

follow the link for implementation

http://www.developerfusion.com/code/4630/capture-a-screen-shot/

Ulaga
  • 863
  • 1
  • 8
  • 17
0

I've never tried this my self but here is what I found online in a similer question.

ScreenCapture sc = new ScreenCapture();
// capture the screen and stores it in a image
Image img = sc.CaptureScreen();

Here is the question I got the information from Capture screenshot of active window?

Here is a reference to the site they got the answer from http://www.developerfusion.com/code/4630/capture-a-screen-shot/

Hope this helps.

Edit: Here is another way that I found

private Bitmap Screenshot()
{
    //Create a bitmap with the same dimensions like the screen
    Bitmap screen = new Bitmap(SystemInformation.VirtualScreen.Width,
                                         SystemInformation.VirtualScreen.Height);

    //Create graphics object from bitmap
    Graphics g = Graphics.FromImage(screen);

    //Paint the screen on the bitmap
    g.CopyFromScreen(SystemInformation.VirtualScreen.X,
                             SystemInformation.VirtualScreen.Y,
                             0, 0, screen.Size);
    g.Dispose();

    //return bitmap object / screenshot
    return screen;
}

Reference found here http://en.code-bude.net/2012/12/27/how-to-take-a-screenshot-in-csharp/

Community
  • 1
  • 1
10bit
  • 83
  • 8