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