Nutty, or someone else, re: Applescript

Posted by: Pete

Nutty, or someone else, re: Applescript - 08/30/06 09:27 AM

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>
Posted by: Trog

Re: Nutty, or someone else, re: Applescript - 08/30/06 10:29 AM

Why not just set your account to logout at a specified amount of time?<br><br><br><br><br>
Posted by: Pete

Re: Nutty, or someone else, re: Applescript - 08/30/06 10:32 AM

Because people still need to access my machine for local files, etc. <br><br>
Posted by: Carlos Ysunza

Re: Nutty, or someone else, re: Applescript - 11/29/08 05:53 PM

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 &#8805; (current date) then
tell application "Safari" to quit saving no
else
delay x
my Verify_Process()
end if
end Waiting_Time

----END CODE------

I hope this help