Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quit an application using AppleScript

Whenever I try to quit an application using AppleScript I get the following error

An error of type -9874 has occurred.

The AppleScript command which I am using is

tell application "app_name"
    quit
end tell
like image 864
user475685 Avatar asked Nov 01 '10 07:11

user475685


People also ask

How do I quit an application in OSX?

Press these three keys together: Option, Command, Esc (Escape). * Or choose Force Quit from the Apple menu  in the corner of your screen.

How do I quit AppleScript?

To bypass the quit handler, choose Quit from the applet's menu while holding down the Shift key, or press the Command-Shift-Q key combo while the applet is the active or front application.

Does Apple still use AppleScript?

AppleScript is a scripting language created by Apple Inc. that facilitates automated control over scriptable Mac applications. First introduced in System 7, it is currently included in all versions of macOS as part of a package of system automation tools.

Is it good to quit applications on Mac?

If you use an app only occasionally, you may want to quit the app when you're done using it, especially if the app uses significant energy. To quit an app, choose App Name > Quit App in the menu bar. For example, choose Preview > Quit Preview (or press the keyboard shortcut Command-Q).


1 Answers

Are you sure that "app_name" exists ? If it does exist, are you sure that it knows how to respond to AppleEvents (is "AppleEvent-aware") ? Try the following test - launch Activity Monitor (in /Applications/Utilities) and run this script:

tell application "Activity Monitor"
    quit
end tell

This works fine for me - if it works OK for you then the problem is probably with your specific application. If it doesn't work for you then you have some kind of system-related problem - try it on a different Mac to verify ?

like image 145
Paul R Avatar answered Oct 22 '22 20:10

Paul R