C # Hide the main form of the automatic screenshot capture program in screen monitoring, which is only displayed in the process

Source: Internet
Author: User

[Csharp]
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Linq;
Using System. Text;
Using System. Windows. Forms;
 
Namespace Screen
{
Public partial class Form1: Form
{
Public Form1 ()
{
// The desktop of the main form is not displayed only in the process
InitializeComponent ();
This. WindowState = FormWindowState. Minimized;
This. ShowInTaskbar = false;
SetVisibleCore (false );
}
Protected override void SetVisibleCore (bool value)
{
Base. SetVisibleCore (value );
}
 
Private void timereffectick (object sender, EventArgs e)
{
// Obtain the current screen size
Rectangle rect = new Rectangle ();
Rect = System. Windows. Forms. Screen. GetWorkingArea (this );
Size mySize = new Size (rect. Width, rect. Height );
Bitmap bitmap = new Bitmap (rect. Width, rect. Height );
Graphics g = Graphics. FromImage (bitmap );
G. CopyFromScreen (0, 0, 0, 0, mySize );
String ImageName = DateTime. Now. ToString ("yyyyMMdd_hhmmss") + ". jpg ";
Bitmap. Save ("F: // screen //" + ImageName );
// Release resources
Bitmap. Dispose ();
G. Dispose ();
GC. Collect ();
}
 
Private void Form1_Load (object sender, EventArgs e)
{
Timer1.Enabled = true; // activate the timer control
}
}
}

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.