A class that will help you take screenshots quickly and easily.

Following are the features of this class:
- Take screenshot of the whole screen
- Take screenshot of a particular area using a Rectangle
- Copy the screenshot to Clipboard.
- Save the screenshot straight after it is captured.
- All popular image formats are supported.
How to use?
To import this class into your C# project all you have to do is to drag and drop the “ScreenCapture.cs” file into your project.
It is very simple to use this class. Here’s an overview of all the features:
// Add this code to the top of your code
// i.e: add it above "public Form1() { ......"
SC.ScreenCapture SC = new SC.ScreenCapture();
// To take a screenshot of the whole screen
// Use this code:
SC.CaptureScreen();
// If you want to save the screenshot straight after it is taken
// Use this code:
// Replace "C:\\screenshot.jpg" with your own path
SC.CaptureScreen(@"C:\screenshot.jpg");
// To take screenshot of a particular area
// Use this code:
// Replace "Rect" with a Rectangle
SC.CaptureRectangle(Rect);
// To save the screenshot straight after it is taken
// Use this code:
// Replace "C:\screenshot-rect.jpg" with your own path and "Rect" with a rectangle.
SC.CaptureRectangle(Rect, "C:\\screenshot-rect.jpg");
// Note: Use the code below after you've taken a screenshot.
// To copy the screenshot to Clipboard
// Use this code
SC.CopyToClipboard();
The above instructions showed you all the features this class offers. However, if you want to see this class in acton. Then I’ve made a simple application for you, which uses this class. Download the class alone or the sample application below:
Dowload the ScreenCapture class and a sample application
ScreenCapture Class – Download Now (1 Kb)
Sample Application – Download Now (46 Kb)
Thanks so much. This is what I was looking for.
Do you have the VB.NET version of it?
No, I wrote this exclusively for C#.
There is a similar one available for VB, visit this link:
http://www.vbforums.com/showthread.php?t=385497
Hope that helps.
Thanks
thanks for that
Nice article, are you seling links from your website? I’m interested…
Yes, email me at:
farooqaaa [at] gmail.com
Thanks.
It makes sense on paper, but does not import properly into C#. Getting CaptureRectangle type doesn’t exist within the context.
Included ScreenCapture.cs and even tried using CS; in the includes section… Any Ideas?
Make sure the namespace for the ScreenCapture class and the form you are using it on is the same.
I’d like to use this program to capture a rectangle. How would I go about getting the button to capture predefined coordinates of the screen??
IE:
public void button2_Click(object sender, EventArgs e)
{
CaptureRectangle(100,100,20,20);
}
Include the ScreenCapture.cs file into your project.
Declare this class-level variable:
SC.ScreenCapture Capture = new SC.ScreenCapture();
To capture an image of predefined coordinates and save it in a Bitmap use this code for your button:
public void button2_Click(object sender, EventArgs e){
Bitmap screenshot;
screenshot = Capture.CaptureRectangle(100,100,20,20);
}
Thanks for the quick response, but it still returns errors about its arguments. Looking at the actually CaptureRectangle statement it wants Rectangle rect, string fileName. Maybe i have to declare what the rectangle is elsewhere, i’ll putz around with it some more, thanks.
Sorry, I forgot that.
Declare a Rectangle class instance and use it as an argument:
public void button2_Click(object sender, EventArgs e){
Rectangle rect = new Rectangle(100,100,20,20);
Bitmap screenshot;
screenshot = Capture.CaptureRectangle(rect);
}
Wow, works like a charm. Thanks for all your help