1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

A script that does what?!?

Discussion in 'Mac Programming' started by nifty_nigel10, Aug 9, 2006.

  1. macrumors member

    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?
  2. macrumors 6502a

    elfin buddy

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

    tell application "Safari"
    end tell
    Just replace Safari with the name of whatever other application you want to quit. That includes the Finder ;)
  3. macrumors 68040


    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.
  4. macrumors member

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


    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.
  6. macrumors 68000


    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.
  7. macrumors 6502a

    elisha cuthbert

    I thought the apple script they used at the WWDC was just a hide all, at least thats what my eyes said
  8. Moderator


    Staff Member

    Just out of interest, would

    tell every application
    end tell

  9. macrumors 68000


    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.
  10. macrumors 65816


    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.

  11. macrumors 68000


    If you want to see this, I give you the link to my archive of scripts.


    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).
  12. macrumors G4


    This link is for a PDF called Applescript for Absolute Starters which is excellent if you are a total applescript beginner.
  13. macrumors 65816


    My script is that bad, huh?
  14. macrumors 68000


    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.
  15. macrumors G4


    Not at all, your script is actually useful! Just a 100 page pdf is more comprehensive ;).

Share This Page