The following code can get the system idle time.
function IdleTime: DWord;
var
LastInput: TLastInputInfo;
begin
LastInput.cbSize := SizeOf(TLastInputInfo);
GetLastInputInfo(LastInput);
Result := (GetTickCount - LastInput.dwTime) DIV 1000;
end;
Is it possible to get keyboard idle time alone? Let the user move his/her mouse-it doesn't matter. Is it possible to determine, how long the keyboard has been idle?
You have to hook to Keyboard event. Check the Keyboard or mouse hooking in Delphi at
http://delphi.about.com/od/kbwinshell/a/delphi_hook.htm
and
http://delphi.about.com/od/windowsshellapi/a/delphi-hooks.htm
You can build your logic over this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With