Looking for way to control logoff


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.

on idle -- this will make the app repeat.
	tell application "System Events"
		if not (exists (process "iMovie")) then
			log out
			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.

There may be other options

Try this:

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).


You know re reading the OP’s post I’m wondering if they are talking about sleep rather than log-out.

But just to point out that if thats not the case your part of the script should be.

tell application "System Events" to ¬
	if "Hway" is not in (creator type of processes) then log out

It sounds to me like simon_b doesn’t want the system to log out if iMovie is running. This is different from logout if iMovie is not running.

?? Do you mean if iMovie is doing something i.e rendering. rather than just being open.

Thank you so much for such a response! :slight_smile:

What we are looking for is to prevent the machine from logging out if imovie is running.

I will try some of the above to see if it works.

Thanks again