public static uint GetIdleTime() { var lastInPut = new LASTINPUTINFO(); lastInPut.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInPut); GetLastInputInfo(ref lastInPut); return ((uint)Environment.TickCount - lastInPut.dwTime); }
public static long GetLastInputTime() { var lastInPut = new LASTINPUTINFO(); lastInPut.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInPut); if (!GetLastInputInfo(ref lastInPut)) { throw new Exception(GetLastError().ToString()); } return lastInPut.dwTime; }
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);