function SecondsIdle: DWord; var liInfo: TLastInputInfo;
begin
liInfo.cbSize := SizeOf(TLastInputInfo);
GetLastInputInfo(liInfo);
Result := (GetTickCount - liInfo.dwTime) DIV 1000;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.Caption := Format('System IDLE last %d seconds', [SecondsIdle]);
end;