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