System Inactive

Hi,

How can I find out the duration for which Windows has been left inactive by the user (i.e. no user input)?

Many thanks,
Lea Hayes

[156 byte] By [NumberKruncher] at [2007-12-31]
# 1

Hi all,

I eventually worked out a way of achieving this; there is an API call which can be used:

[DllImport("User32.dll")]
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
[
DllImport("Kernel32.dll")]
private static extern uint GetTickCount();

internal struct LASTINPUTINFO
{
public uint cbSize;
public uint dwTime;
}

private uint GetIdleTime()
{
LASTINPUTINFO lastInPut = new LASTINPUTINFO();
lastInPut.cbSize = (
uint)Marshal.SizeOf(lastInPut);
return GetTickCount() - lastInPut.dwTime;
}

Many thanks,
Lea Hayes

NumberKruncher at 2007-9-7 > top of Msdn Tech,Visual C#,Visual C# General...