Exemplo n.º 1
0
        private static void Timer_Tick(object sender, EventArgs e)
        {
            TAGLASTINPUTINFO LastInput = new TAGLASTINPUTINFO();

            LastInput.cbSize = (uint)Marshal.SizeOf(LastInput);
            LastInput.dwTime = 0;
            if (!Interop.GetLastInputInfo(ref LastInput))
            {
                return;
            }
            int IdleTime = Environment.TickCount - LastInput.dwTime;

            Console.WriteLine($"No user input: {IdleTime}ms");

            if (IdleTime < 5000)
            {
                return;                  //5 seconds
            }
            DoSoftwareProcess();
        }
Exemplo n.º 2
0
 public static void Start()
 {
     while (true)
     {
         TAGLASTINPUTINFO LastInput = new TAGLASTINPUTINFO();
         LastInput.cbSize = (uint)Marshal.SizeOf(LastInput);
         LastInput.dwTime = 0;
         if (!Interop.GetLastInputInfo(ref LastInput))
         {
             return;
         }
         int IdleTime = Environment.TickCount - LastInput.dwTime;
         Console.WriteLine($"Meantime software doing it's heavy process idletime has been reset");
         if (IdleTime < 2000)
         {
             return;                  //2 seconds
         }
         ResetIdle();
         Thread.Sleep(100);
     }
 }
Exemplo n.º 3
0
 public static extern Boolean GetLastInputInfo(ref TAGLASTINPUTINFO plii);