.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> System Process >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to capture/store screen shot

Posted By:Sajid P K       Posted Date: October 11, 2010    Points: 15    Category: System Process    URL: http://www.dotnetspark.com  

Here I am trying to simulate "print screen" using C#.
 

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

 

Follwing is the code for that.

  ///


    /// capture/store the screen shot
    ///

    /// true-Active screen  
    /// image
    public static Image GetScreenShot(bool currentScreen)
    {

        if (currentScreen)
            // Simulate Alt+PrtScn keypress.
            SendKeys.Send("{%}({PRTSC})");
        else
            // Simulate PrtScn keypress.
            SendKeys.Send("{PRTSC}");

        // 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.


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend