Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Use applescript to force quit apple script application?

I tried to use applescript to force quit an applescript application that continues running after the end of the script, i used

do shell script {"killall (appname)"} and it said it could not find that app

also, just curious, let's say you have script a activate script b, is script a supposed to stay running until script b stops running, then go on to the next line? and is script b not allowed to make script a quit? because thats whats happening right now.

MacBook Pro

Posted on Nov 27, 2014 6:45 PM

Reply
5 replies

Nov 28, 2014 6:34 AM in response to randomaccountgenerator157

If your script includes an "on idle" handler and is saved as a stay-open application, you should include a quit handler:


on quit

-- maybe do other stuff

continue quit

end quit


This will let you quit the script application using the Quit command in its menu or by typing Cmd-Q while it is active.


From the ASLG:


Warning: If AppleScript doesn’t encounter a

continue quit
statement while executing an
on quit
handler, it may seem to be impossible to quit the application. If necessary, you can use Force Quit (Command-Option-Esc) to halt the application.


AFAIK if you want to sent a quit command from another script, you would have to create a full-blown application using XCode and make the application scriptable. And that's another kettle of fish...

Nov 28, 2014 9:43 AM in response to HD

HD: two clarifications:


  1. on quit handlers are not needed unless you want to do something before the app quits: e.g., save data or some such. If you use an on quit handler you need the continue quit line or the app will never quit, true, but you don't need to use the handler unless you have a purpose for it.
  2. Applescript applications are already scriptable: you can say something like tell application "Script App" to quit from the script editor or a separate script application and it will work. If the script app does not have a unique name, you may need to go into the package contents, open the info.plist file, and find its bundle id (or create one for it) so that the system can find it, but there is no need to break out Xcode.

Use applescript to force quit apple script application?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.