I work for a digital media centre at a university. We are trying to find a way using applescript that would allow us to have the machines logoff after a certain amount of time (which we can already set via the preferences dialog) but we also need it to not log off if a certain program is running. The Reason for this is we use our macs for mainly video editing and large renders are usually left over night. If the machine logs out during this time the render is stopped.
I am totally new to applescript but this is where I am so far:
tell application "System Events" to (name of processes) contains "imovie 6"
if result is true then
Thats pretty much where I’ve gotten lost. Any help would be appriciated.
Cheers.
on idle -- this will make the app repeat.
tell application "System Events"
if not (exists (process "iMovie")) then
log out
else
return 60 (* if the process does not exist then 60 is returned.
which in this case will be 60 seconds. The 60s is passed on to the idle handle
which will repeat in 60 seconds *)
end if
end tell
end idle
Save as a application. and Stay open ticked.
(also only have iMovie HD myself so thats the name I tested it with.
You should note, any unsaved work may cause the log-out to fail.
tell application "System Events" to ¬
if "Hway" is in (creator type of processes) then log out
“Hway” is the creator type of iMovie. This way, System Events will locate the process in despite of the app name (if you must manage different-named apps, depending on the machine).