C#winform the mouse 30 seconds to close the window

Source: Internet
Author: User

    Public partial class Baseform:form {private timer timer;        int x, y;        DateTime start;         BOOL FF = true;            Public BaseForm () {timer = new timer ();            x = control.mouseposition.x;            y = control.mouseposition.y; Timer.            Interval = 1000; Timer.            Tick + = new EventHandler (Timer_tick); Timer.        Start ();            } protected void Timer_tick (object sender, EventArgs e) {int x1 = control.mouseposition.x;            int y1 = CONTROL.MOUSEPOSITION.Y;                if ((x = = x1) && (y = = y1) && ff) {start = DateTime.Now;            FF = false;                } if (x! = X1 | | Y! = y1) {x = x1;                y = y1;                start = DateTime.Now;            FF = true;            } TimeSpan ts = DateTime.Now.Subtract (start); if (TS.  Seconds > 5) environment.exit (0);Change 5 to 30, which is 30 seconds} protected override bool processCmdKey (ref Message msg, Keys keyData) {St            Art = DateTime.Now; Return base.        processCmdKey (ref msg, keyData); }    }

C#winform the mouse 30 seconds to close the window

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.