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
Press these three keys together: Option, Command, Esc (Escape). * Or choose Force Quit from the Apple menu in the corner of your screen.
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.
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.
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).
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 ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With