Beispiel #1
0
        static uint GetLastInputTime()
        {
            uint          idleTime      = 0;
            LastInputInfo lastInputInfo = new LastInputInfo();

            lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            uint envTicks = (uint)Environment.TickCount;

            if (GetLastInputInfo(ref lastInputInfo))
            {
                uint lastInputTick = lastInputInfo.dwTime;

                idleTime = (envTicks - lastInputTick);
            }

            return((idleTime > 0) ? (idleTime / 1000) : idleTime);
        }
Beispiel #2
0
 private static extern bool GetLastInputInfo(ref LastInputInfo ptrInputInfo);