Screen Monitoring Utility

Introduction
 

The directory is created hidden and all the snapshots are created within the directory. The basic idea is to do the work of the "Print Screen" utility. For an improvement I have used a timer which will take the input from the user and create the snapshots on a regular interval.
 
The Namespaces
 
using System.IO; //for working with the directories.
using System.Drawing.Imaging; //for working with the images and graphics.
 

The Code
 

First, we will see how we can create a directory, also hidden. See:
 
DirectoryInfo di = Directory.CreateDirectory(@"C:\Snap");
di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
 

Now create the file named interval.txt and write the interval to it so it can be used in the future. We will be seeing it later. See:
 
File.WriteAllText(@"C:\Snap\interval.txt", textBox1.Text);
 

Now let's focus on the main function of the program. That is to take the screen shots.
 
Create the new image with screen bounds as its parameters, as in:
 
Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
 

Create a graphics object with that image and use the CopyFromScreen() method to copy the screen bounds, then save it in the directory created above.
 
Graphics gr = Graphics.FromImage(bmp);
gr.CopyFromScreen(0, 0, 0, 0, bmp.Size);
string str = string.Format(@"C:\Snap\Snap[{0}].jpeg", c);
 

c is the count which is incremented to change the name of the saved file, otherwise it will be overwritten again and again.
 
To close it we have to open the task manager and close the task from there only, otherwise it will not end.
 
Now when you again open this application it will take the previous value from the file (don't make changes in the file named interval.txt, however you can view its content) and will be started in hidden mode without any knowledge of the user.
 
*For full soucre and exe download the attachments.
 
*Before starting please read the steps.

Up Next
    Ebook Download
    View all

    FileInfo in C#

    Read by 9.7k people
    Download Now!
    Learn
    View all