[fpc-pascal] Getting Last User Input reliably

Luca Olivetti luca at ventoso.org
Fri Dec 3 16:59:22 CET 2021


El 3/12/21 a les 16:41, Travis Siegel via fpc-pascal ha escrit:
> 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.


I suppose he wants to check for any activity, not just for input 
directed at his application.
One possibility is to have a thread calling GetLastInputInfo cyclically 
(say, every second or every half second), if the dwTime changed just 
register the current GetTickCount64 as the time of the input.
That should work unless the new input happens exactly after 49.7 days 
(that's the rollover time, not 25 days) from the last one, at the same, 
exact, millisecond. Quite improbable but not impossible.
Oh, and keep in mind that in older versions of windows there's no 
GetTickCount64, the rtl simulates it by using.....GetTickCount.
Windows Vista and above should be fine though.

Bye
-- 
Luca


More information about the fpc-pascal mailing list