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

    #1
    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

    #2
    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 ;)
     
  3. macrumors 68040

    mduser63

    #3
    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

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

    #5

    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

    Soulstorm

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

    elisha cuthbert

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

    Nermal

    Staff Member

    #8
    Just out of interest, would

    tell every application
    quit
    end tell

    work?
     
  9. macrumors 68000

    Soulstorm

    #9
    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

    Unorthodox

    #10
    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

    Soulstorm

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

    Eraserhead

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

    Unorthodox

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

    Soulstorm

    #14
    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

    Eraserhead

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

Share This Page