Search code examples
c#screenshotactive-window

Capture screenshot of active window?


I am making a screen capturing application and everything is going fine. All I need to do is capture the active window and take a screenshot of this active window. Does anyone know how I can do this?


Solution

  • ScreenCapture sc = new ScreenCapture();
    // capture entire screen, and save it to a file
    Image img = sc.CaptureScreen();
    // display image in a Picture control named imageDisplay
    this.imageDisplay.Image = img;
    // capture this window, and save it
    sc.CaptureWindowToFile(this.Handle,"C:\\temp2.gif",ImageFormat.Gif);
    

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