Best way to set up an idle timer
Sarah
sarahr at genesearch.com.au
Thu Aug 14 19:44:01 EDT 2003
> I want to write a routine in my stack that will automatically log the
> user out after X minutes of inactivity, in the same way the screen
> saver will kick in after X minutes. Any mouse or keyboard event would
> reset the timer. I've been playing with the idle handler like this:
script snipped
> The problem with this approach of course is there is no way to reset
> the startSeconds unless the timeOut handler runs. I don't want to have
> to trap every single mouse and keyboard event to reset startSeconds.
An idle handler is a bad idea as it tries to hog the processor. It is
always better to use a send instead. I would recommend something like
this:
on openStack
put the seconds into startSeconds
send "logoutMessage" to me in 300 seconds
....
end openStack
on resetLogout
-- cancel any pending logoutMessage
-- send a new one 5 minutes from now
end resetLogout
on logoutMessage
-- do the actual logout stuff
end logoutMessage
Then have a frontScript that tracks rawKeyDown and mouseDown (or
mouseMove if that is enough to stop being logged out), and sends a
resetLogout message after each one before passing it on.
Cheers,
Sarah
sarahr at genesearch.com.au
http://www.troz.net/Rev/
More information about the use-livecode
mailing list