The "tell me to quit" statement is very useful when you run an applescript as an applet or from the script menu, however when developing or debugging scripts in Script Editor it is very annoying since it quits Script Editor rather than just stopping the execution of the script.

Two questions:

  1. Is it possible from within a script to check what environment it runs in, something like

    if environment is applet then tell me to quit else display notification "Done"

  2. How do I exit just the script when it is run in Script Editor? That is, the same result as when you click the stop button in the toolbar.

1 Answer 1


Current Application

You can get the name of the current application. If the name is Script Editor, then your AppleScript is being run within the editor:

display dialog (name of current application as text)

Detecting the Environment

Alternatively, your AppleScript can access environment variables through the system attribute command. You should be able to determine your process through this information. To see the HOME path environment, use:

display dialog (system attribute "HOME")

Stopping an AppleScript

To stop the script use the return command. In the AppleScript snippet below, the dialog is never displayed:

display dialog "Hello World"

return exits the current routine within AppleScript; much like return in other languages such as c. Called within the context of the main AppleScript routine, there is nothing to return to, so the script finishes.

Compare this to tell me to quit, where the snippet causes a quit AppleEvent to be issued to the current process.

  • Thank you. What's the difference between "return" and "tell me to quit" beyond that "tell me" quits the Script Editor if the script is run from within it.
    – d-b
    Oct 4, 2017 at 14:02
  • 1
    I have expanded the answer. Hopefully this helps. Oct 4, 2017 at 14:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .