C # sample code for regularly taking full screen screenshots and saving them to preset folders

Source: Internet
Author: User

C # sample code for enabling timed full screen and saving it to a preset folder

Customize a function,

Public static void Snap (int x, int y, int width, int height)
{
Try
{

// This code can also be implemented
// Image image = new Bitmap (width, height );
// Graphics g = Graphics. FromImage (image );
// G. CopyFromScreen (x, y, 0, 0, new System. Drawing. Size (width, height ));
// String hour = DateTime. Now. Minute. ToString ();
// String second = DateTime. Now. Second. ToString ();
// Image. Save (ScreenshotPath + "\" + hour + "_" + second + ". jpg ");




Bitmap image = new Bitmap (GetSystemMetrics (0), GetSystemMetrics (1 ));
Using (Graphics g = Graphics. FromImage (image ))
{
G. CopyFromScreen (0, 0, 0, 0, image. Size );
G. Dispose ();
String hour = DateTime. Now. Minute. ToString ();
String second = DateTime. Now. Second. ToString ();
Image. Save ("C:" + "\" + hour + "_" + second + ". jpg ");
}
}
Catch
{


}
}

 

Then, call the custom function in a timerSrc_Tick, and save it to the specified folder at regular intervals.

Private void timerSrc_Tick (object sender, EventArgs e)
{
Help. Snap (0, 0, Screen. PrimaryScreen. Bounds. Width, Screen. PrimaryScreen. Bounds. Height );
}

However, after running this code, you may find that it can be implemented, but some software cannot be accessed after it is opened. For example, you can open a QQ login window, however, you did not find a logon window for QQ. This problem was accidentally discovered after I wrote it. However, because I am also a cainiao, you can refer to it if the requirement is not high, however, if you need to take a screenshot of all the images on the screen, you can study the code and give me a copy of the code. Hope to help you

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.