Best way to set up an idle timer

Devin Asay devin_asay at byu.edu
Thu Aug 14 16:54:00 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:

global startSeconds

on idle
   if startSeconds is empty then
     put the seconds into startSeconds
   end if
   if the seconds - startSeconds > 5 * 60 then timeOut -- for a 5 min. 
timeout
end idle

on timeOut
   answer "time's up!"
   put empty into startSeconds
end timeOut

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.

I know there has to be an easy way to do this. My brain is just not 
grasping it today.


Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list