Member Since: Aug 13, 2011
Location: West Sussex, UK
12-24-2011, 06:04 PM
I have done a fair bit of Applascript, and I can tell you there is no better way with Applescript.
As for Xcode it does not have any quick ways to do what you want, dvelopers did use the keystroke cmd-o, but this does not minimize windows, but hides them, this technique is not avised by apple, or me.
I have tried this simular script to yours, and it closed five apps in about one minute, so you must have a lot of apps running.
tell application "System Events"
set visible_app_list to every application process whose visible is true
repeat with visible_app in visible_app_list
tell application process visible_app
click (first button of every window of visible_app whose role description is "minimize button")
You have to remember to have GUI scripting enabled in System Preferences.
Also bare in mind, that different apps take a different amount of time to quit