PDA

View Full Version : A script that does what?!?




nifty_nigel10
Aug 9, 2006, 01:56 PM
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
Aug 9, 2006, 04:41 PM
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:

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
Aug 9, 2006, 04:52 PM
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
Aug 9, 2006, 07:26 PM
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
Aug 9, 2006, 07:27 PM
I'm no AppleScript pro, but to get you started, here's a little piece of code that will quit Safari:

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
Aug 10, 2006, 04:35 AM
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.

elisha cuthbert
Aug 10, 2006, 05:10 AM
I thought the apple script they used at the WWDC was just a hide all, at least thats what my eyes said

Nermal
Aug 10, 2006, 05:15 AM
tell application "Safari"
close every window
end tell

Just out of interest, would

tell every application
quit
end tell

work?

Soulstorm
Aug 10, 2006, 05:24 AM
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
Aug 11, 2006, 10:13 AM
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

Soulstorm
Aug 12, 2006, 11:53 AM
If you want to see this, I give you the link to my archive of scripts.

http://users.forthnet.gr/ath/jonmecos/Mainsite/Development/archives/prg/

It contains common sub-routines and some handy applications. These are scripts created some years ago, but they should still work. You may take some ideas from there... (although I was pretty young when I was creating them).

Eraserhead
Aug 12, 2006, 01:42 PM
This (http://files.macscripter.net/sourcebook/AS4ASb2.pdf) link is for a PDF called Applescript for Absolute Starters which is excellent if you are a total applescript beginner.

Unorthodox
Aug 12, 2006, 02:30 PM
This (http://files.macscripter.net/sourcebook/AS4ASb2.pdf) link is for a PDF called Applescript for Absolute Starters which is excellent if you are a total applescript beginner.
My script is that bad, huh?

Soulstorm
Aug 12, 2006, 03:50 PM
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.

Eraserhead
Aug 13, 2006, 04:52 AM
My script is that bad, huh?
Not at all, your script is actually useful! Just a 100 page pdf is more comprehensive ;).