How to capture/store screen shot

We all are familiar with taking screen shot manully by pressing “Print Screen” key. There are two alternative for using “Print Screen” key

1) Alt+PrtScn -Image of active screen
2) PrtScn - Image of Desktop

Here I am trying to simulating above two method using C#.

/// <summary>
/// capture/store the screen shot
/// </summary>
/// <param name="currentScreen"> true-Active screen </param>
/// <returns>image</returns>
public static Image GetScreenShot(bool currentScreen)

if (currentScreen)
// Simulate Alt+PrtScn keypress.
// Simulate PrtScn keypress.

// Get the image from the clipboard.
return (Image)Clipboard.GetImage();


In the above example, GetScreenShot() function gets the screen shot and returns an Image object from the Clipboard.


Author: Shashwath7730 Aug 2010 Member Level: Gold   Points : 0

pl tell me wat are the namespaces required

Author: Pal (Parthiv) Patel31 Aug 2010 Member Level: Gold   Points : 1

this one is awesome code snippet
keep it up
put good codes and earn money and points

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: