Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check if computer is idle

Status
Not open for further replies.

PlutoDev

Programmer
Sep 21, 2002
25
0
0
ID
hi..
I need to check if computer is idle more than 3 minutes..
I did it by checking mouse pointer.. But sometimes
user just using keyboard and mouse pointer(x,y) is
getting wrong.. So, I need to detect IDLE like windows'
screen-saver process.. How can I detect if computer is
idle (probably some minutes that I can set)...
Thanks..
 
This will work for Windows 2000 and above

Code:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
 Caption := Format('System IDLE last %d seconds', [SecondsIdle]) ;
end;

function TForm1.SecondsIdle: DWord;
var
   liInfo: TLastInputInfo;
begin
   liInfo.cbSize := SizeOf(TLastInputInfo) ;
   GetLastInputInfo(liInfo) ;
   Result := (GetTickCount - liInfo.dwTime) DIV 1000;
end;

set the timer to an interval for checking 5-10 seconds should do!!

Kind Regards, Paul Benn

**** Never Giveup, keep trying, the answer is out there!!! ****
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top