[fpc-pascal] Getting Last User Input reliably
Travis Siegel
tsiegel at softcon.com
Fri Dec 3 16:41:21 CET 2021
If there's some sort of a configuration file, just write out the
time/date info at the time of leaving the input, then when that routine
gets called again, grab the current time/date, and perform a
comparison. That should allow you to bypass any roll overs of any kind
(unless it goes past the operating system's time keeping abilities),
which isn't likely.
On 12/3/2021 10:30 AM, Luca Olivetti via fpc-pascal wrote:
> 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
More information about the fpc-pascal
mailing list