PDA

View Full Version : "Close All" After 60s Inactivity AppleScript




ApplGuy
Jul 23, 2009, 02:51 PM
Hey everyone. I've done a bit of searching on here, but can't seem to find the answer to my question. If this is a double post, please just direct me to the relevant threads.

I have several mac computers that run a demo loop throughout the day to attract customers to use them. The demo loop I have runs automatically after 60 seconds of inactivity, but it doesn't close any applications or windows that the user may have opened. After a few hours, almost every program is running and the machines tend to get a bit slow. I also utilize the automatic shut down and boot feature of Leopard, and sometimes some of the open programs prevent the machines from turning off.

What I want to happen is for an AppleScript or something to run after 60 seconds of inactivity to quit all open applications and windows without saving or anything. Basically a force quit, but with a proper shut down of the programs. Then the demo loop should launch and run. Then when someone then uses the computer, the loop automatically exits and the Script will begin waiting until 60 seconds of inactivty before closing all windows and programs and running the loop again.


The following AppleScript works to close all applications:

tell application "Finder"
set psNames to (name of application processes whose visible = true) as list
end tell

repeat with i from 1 to (count of psNames)
set app2Kwit to item i of psNames as text
tell application app2Kwit to quit
end repeat


Can someone help me out by expanding around this code so that it waits for 60 seconds of inactivity before executing?


Finally, if I've got Automator down right I should just be able to build a workflow that incorporates the code from here (once the timer is built in) and then launches the demo loop after it runs.


Thanks in advance for your help.

ApplGuy