Re: [fpc-pascal] Getting Last User Input reliably

2021-12-06 Thread wkitty42--- via fpc-pascal
On 12/5/21 11:10 AM, James Richters via fpc-pascal wrote: So the only thing I need to consider is times of longer than 49.7 days without user input... because if it was exactly 50 days, it would look like 0.3 days as the first rollover would be forgotten. To take care of this I can just check it

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-05 Thread Sven Barth via fpc-pascal
James Richters via fpc-pascal schrieb am So., 5. Dez. 2021, 19:06: > Is there some way I can do {$Q-} before my check then restore it to > whatever it was before after it? (for example if it was already set to > {$Q-} in the compiler, I would not want to turn it back on) > Is there a way to do a

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-05 Thread James Richters via fpc-pascal
Thanks for the explanation. This works the way I want it to... working with the rollover without causing an overflow error even if I leave overflow checking turned on. DWord((QWord(GetTickCount) - QWord(Last_Input_Info.dwTime)) AND $) James

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-05 Thread James Richters via fpc-pascal
Oh I see.. it does work on DWord.. I was testing it with constants: Writeln($FFFE+$0006); But I think the compiler resolved this so it would never create a overflow error.. When I do it with variables now I get the overflow and I can control it with {$Q-} and {$Q+} Is there some way I

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-05 Thread Jonas Maebe via fpc-pascal
On 05/12/2021 17:10, James Richters via fpc-pascal wrote: I did some tests and went to go turn on Overflow checking just to see what would happen... and noticed it was on already... but I noticed it's called "Integer Overflow Checking" which seems it would not apply to things specifically set

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-05 Thread James Richters via fpc-pascal
Indeed keeping it a DWord solves all the problems for any amount of time less than the 49.7 day rollover time and I don't even have to check for the rollover because it takes care of itself by doing unsigned arithmetic. Is there even such a thing as overflow checking for DWord variables? I did

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-03 Thread Luca Olivetti via fpc-pascal
El 3/12/21 a les 18:37, Dennis Lee Bieber via fpc-pascal ha escrit: Detection is normally done by: if current tick is less than saved tick, roll-over has occurred. Make adjustments to the delta. There is no need to do that, just make sure you're using DWORDs (i.e. unsigned

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-03 Thread Luca Olivetti via fpc-pascal
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

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-03 Thread Travis Siegel via fpc-pascal
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

Re: [fpc-pascal] Getting Last User Input reliably

2021-12-03 Thread Luca Olivetti via fpc-pascal
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

[fpc-pascal] Getting Last User Input reliably

2021-12-03 Thread James Richters via fpc-pascal
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; This works most of the time, but every 25 days or so GetTickCount rolls over,