none
Help in Code, Timer will start after 15 minutes of no movement in computer. and will stop if you move it again. RRS feed

  • Question

  • I already finish this timer. but additionally i want this timer to stop when the IDLE timer starts. then this timer resumes when there is movement in the pc again then IDLE timer stops.

    namespace TITOMS_LOGIN
    {
        public partial class Form3Admin: Form
        {
            int seconds;
            int minutes;
            int hours;
            public Form3Admin()
            {
                InitializeComponent();
                seconds = minutes = hours = 0;


            }

            private void button1_Click(object sender, EventArgs e)
            {
                this.Hide();
                Form2Admin sw = new Form2Admin();
                sw.Show();
            }

            private void button3_Click(object sender, EventArgs e)
            {
                this.Hide();
                Form5 se = new Form5();
                se.Show();
            }

            private void Form3Admin_Load(object sender, EventArgs e)
            {

                Time.Text = DateTime.Now.ToShortTimeString();
                Day.Text = DateTime.Now.ToLongDateString();
            }

            private void timer1_Tick(object sender, EventArgs e)
            {
                seconds++;

                if (seconds > 59)
                {
                    minutes++;
                    seconds = 0;
                }

                if (minutes > 58)
                {

                    hours++;
                    minutes = 0;

                }

                lblhours.Text = hours.ToString() + "HRS";
                lblminutes.Text = minutes.ToString() + "MINS";
            }

            private void button4_Click(object sender, EventArgs e)
            {
                timer1.Start();
            }

            private void button5_Click(object sender, EventArgs e)
            {
                timer1.Stop();

            }


        }
    }

     
    Thursday, October 10, 2019 3:41 AM

All replies