#286786 - 08/30/0609:27 AMNutty, or someone else, re: Applescript
Pete
www.workwithpete.com
Registered: 06/17/03
Posts: 5996
Loc: United States
Was it nutty who knows this stuff? Can't remember.<br><br>Anyway, is there a way to write an Applescript (or Automator action) that will quit out of Safari (no questions asked) if the program is idle after a certain amount of time? I check my ISP's webmail here at work, but certain times I'll leave it open by mistake when I leave for the day - and if I'm out the following day it remains 'logged in' for anyone (who may need to use my machine) to see & read my messages. <br><br>Help?<br><br>
this code do the job, don't know if is the most efficient way but I think it works. if not you have something to start your own script
1.- Copy the code 2.- Paste in ScriptEditor 3.- define x as a number of minutes you want to wait 4.- Save as application WHIT stay open option cheked
---START CODE---- property x : 5 * minutes -- YOU NEED TO GIVE THIS NUMBER I PUT "5" BUT CAN BE ANY global StartTime
set StartTime to (current date) my Verify_Process()
on Verify_Process() if Check_ActiveApp() then my Reset_StartTime() else my Waiting_Time(x) end if end Verify_Process
on Reset_StartTime() set StartTime to (current date) end Reset_StartTime
on Check_ActiveApp() tell application "System Events" frontmost of application process "Safari" end tell end Check_ActiveApp
to Waiting_Time(x) set StartTime to (current date) + x * minutes if StartTime ≥ (current date) then tell application "Safari" to quit saving no else delay x my Verify_Process() end if end Waiting_Time