function LastInput: DWord;
var
LInput: TLastInputInfo;
begin
LInput.cbSize := SizeOf(TLastInputInfo);
GetLastInputInfo(LInput);
Result := GetTickCount - LInput.dwTime;
end;
procedure TForm1.tmr1Timer(Sender: TObject);
begin
lbl1.Caption := Format('System Idle since %d ms', [LastInput]);
end;