C # Implement timed full screen screenshots and save code examples in a pre-set folder

Source: Internet
Author: User

To 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
{


}
}


The custom function is then called in a Timersrc_tick, and then it is scheduled to be saved to the specified folder

private void Timersrc_tick (object sender, EventArgs e)
{
Help.snap (0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
}

But after running this code, careful people may find that can be achieved, but some software is not truncated after opening, such as you open a QQ landing window, but you found that there is no QQ landing window, this problem is I have inadvertently found the problem after writing, but because I am also a rookie, So if the request is not high you can refer to, but if you need to intercept all the pictures on the screen, you can on the basis of this code in the study, by the way also give me a code, also learn, we learn together. I hope it will be helpful to everyone.

C # Implementing timed fullscreen and saving code examples in a pre-set folder

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.