[icq-devel] Input event, was(no subject)

Mark van Cuijk webmaster at phedny.zzn.com
Sat Jan 4 12:07:51 CET 2003


>Turns out that GetLastInputInfo is the way to go

I'll just want to remember you GetLastInputInfo is only available from Win2k and up.

Oh, and a little tip: to reduce the number of checks to a bare minimum, you might consider using the following algorithm:
1) On startup, check GetLastInputInfo to find out the number of msecs since the input occured. Substract this value from the idle-timout and store it to X
2) Start a timer for X msecs
In the timer event, check GetLastInputInfo to determine whether to initiate auto-away or not and, if auto-away is NOT initiated, repeat the above steps.

This way the timer will wait longer when, for example, the mouse has just moved. If the last input was a minute ago, and the time-out is 5 minutes, then the timer will wait 4 
minutes, because in these minutes we're very sure auto-away doesn't need to be initiated. When the timer fires, we do the same check and initiate the timer for another period. 
One important note on this: you must be careful not to initiate the timer when auto-away is about to initiate. If you do, you would substract, for example, 5 minutes from 5 
minutes, the result is zero, in which case the timer would return immediatly and auto-away is initiated again and the timer is launched again...

- Mark

More information about the icq-devel mailing list