Screen Capture Class For C#
Posted on September 18th, 2009 in C#, Tutorials | 3 Comments »

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)
3 Responses
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