Some things to think about: - I am assuming this is stored in file test
- as soon as you stop the app, you restart it, so that is some kind of loop. - you need to reset the handle each time the app is restarted - you are creating an event to run every 3 seconds but the count increments by one; you may want to increment by number of seconds per event (and set lapsed accordingly). Or maybe you are fine with lapsed being just number of times check is made - I don't see any realistic problems with the app being idle for long time -- count will still pass lapsed at some point for all practical examples --- In [email protected], "Peter" <pjaga...@...> wrote: > > The purpose of the script below is to check a particular application's idle > time. If it exceeds a predetermined amount of time, the application is closed > and started again. My fear is whether this script will end up in infinite > loop. I have made remarks within the script where I have concern > *** Start code > static lapsed, count > > local handle > handle= win.handle("=xplorer2_UC") > win.debug("handle:*" ++ handle ++ "*" ) > > if (handle == "") do > if (event.exists(event_handle)) > event_handle=event.destroy(event_handle) > quit > endif > > if (handle == win.handle("active")) do > count =0 > else > count = count + 1 > endif > win.debug("count:" ++ count) > if (count > lapsed ) do > win.close(handle) > if (event.exists(event_handle)) > event_handle=event.destroy(event_handle) > ; PLEASE NOTE NEXT TWO LINES > ; I AM STARTING THE APPLICATION AND > ; CALLING SUBROUTINE WITHIN THIS SCRIPT > ; WHAT WILL HAPPEN IF THE OPENED APPLICATION IS NOT > ; TOUCHED FOR 8 HOURS > ; I HAVE KEPT THE TIME INTERVAL VERY LOW FOR > ; TESTING PURPOSES > do("C:\Program Files\~~File Managers\xplorer2\xplorer2_UC.exe") > .t...@initiate > endif > Quit > > @Initiate > static count = 0 > static lapsed = 5 > static event_handle = event.create(3,0,".test") > *** End Code > > Thanks > > Peter >
