Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nifty_nigel10

macrumors member
Original poster
Jul 14, 2004
48
0
this may be a stupid question, but is there an applescript that closes all open apps? i'm new to the whole applescript thing, thought about writing my own and don't have the faintest clue where to start. can anybody help me out?
 

elfin buddy

macrumors 6502a
Sep 16, 2001
608
0
Tuttlingen, Germany
nifty_nigel10 said:
this may be a stupid question, but is there an applescript that closes all open apps? i'm new to the whole applescript thing, thought about writing my own and don't have the faintest clue where to start. can anybody help me out?

I'm no AppleScript pro, but to get you started, here's a little piece of code that will quit Safari:

Code:
tell application "Safari"
    quit
end tell

Just replace Safari with the name of whatever other application you want to quit. That includes the Finder ;)
 

mduser63

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
It's not all that hard to write a script all open apps, though I'm too lazy to do it now. I did notice during the WWDC keynote that at one point, SJ said something like "Let's close out of all this" then clicked an AppleScript as he was moving on to something else following a demo.
 

nifty_nigel10

macrumors member
Original poster
Jul 14, 2004
48
0
mduser63 said:
It's not all that hard to write a script all open apps, though I'm too lazy to do it now. I did notice during the WWDC keynote that at one point, SJ said something like "Let's close out of all this" then clicked an AppleScript as he was moving on to something else following a demo.

yes thats exactly what made me want to build/find one. but to no avail.
 

nifty_nigel10

macrumors member
Original poster
Jul 14, 2004
48
0
elfin buddy said:
I'm no AppleScript pro, but to get you started, here's a little piece of code that will quit Safari:

Code:
tell application "Safari"
    quit
end tell

Just replace Safari with the name of whatever other application you want to quit. That includes the Finder ;)


i tried that one...with the applications i entered to try out, if they weren't open...they opened them instead of just quiting those already open within the list.
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
Code:
tell application "Safari"
	close every window
end tell
Replace the word "Safari" with the application of your choice. This will work on every application that has a variable "window" defined. You can see that 'every' is an applescript keyword, and 'window' is a window declared in the Safari's applescript dictionary. To see more about applescript support on applications, go to script editor, and choose "Open Dictionary" from the file menu. Choose the application of your choice, and study the reference for this particular application.
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
No. And It's been years since I last got involved with Applescript, so I don't know how can I do what you ask.
 

Unorthodox

macrumors 65816
Mar 3, 2006
1,087
1
Not at the beach...
This script will quit every open application that has a dock icon (except the Finder) and is NOT hidden. So if you hide your apps a lot this script isn't for you.

tell application "Finder"
set dock_app to the name of every process whose visible is true
end tell

repeat with num from 1 to number of items in the dock_app
set this_app to item num of the dock_app
if this_app is not "Finder" then
tell application this_app
quit
end tell
end if
end repeat
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
This link is for a PDF called Applescript for Absolute Starters which is excellent if you are a total applescript beginner.
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
When it comes to languages with limited programmatical freelance, just getting the job done is the only thing you should be concerned about. If it works and perfectly suits your need, it's ok.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.