El 3/12/21 a les 14:52, James Richters via fpc-pascal ha escrit:
I'm trying to get the time lapsed since the last user input with keyboard or
mouse on a Windows PC.  For this I am doing:

GetLastInputInfo(Last_Input_Info);
IdleTime:= (GetTickCount - Last_Input_Info.dwTime) DIV 1000;

I was going to suggest

IdleTime:= DWORD(GetTickCount - Last_Input_Info.dwTime) DIV 1000;


but then I saw

On top of all this, I need to allow for the
possibility that there was no user input for more than 25 days.. which is
quite likely.

so that's not going to work, sorry. I'm using the above for short intervals and it works in spite of the rollover (unless you enabled overflow checking, but that's another issue).

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to