private void OnUserActivityCheckTimer(object info) { LASTINPUTINFO lastInputInfo = new LASTINPUTINFO(); lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo); lastInputInfo.dwTime = 0; int systemUptime = Environment.TickCount; int lastInputTicks = 0; int idleTicks = 0; if (SafeNativeMethods.GetLastInputInfo(ref lastInputInfo)) { lastInputTicks = (int)lastInputInfo.dwTime; idleTicks = systemUptime - lastInputTicks; idleForXSeconds = idleTicks / 1000; } }
internal static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);