Nutty, or someone else, re: Applescript

Posted by: Pete

Nutty, or someone else, re: Applescript - 08/30/06 04:27 PM

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 05:29 PM

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 05:32 PM

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/30/08 01:53 AM

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

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()
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
delay x
my Verify_Process()
end if
end Waiting_Time

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

I hope this help