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
///
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.
No comments:
Post a Comment