iTBotB

Q: AppleScript application won't quit

{Note: Also posted in Snow Leopard section. I use both OS versions.}

 

Here's my simple Applescript application:

     delay 60

     beep 2

 

I run it. It has an icon in the Dock. I right-click icon and choose option Quit. It doesn't quit until the 60 second delay is over. Then, it quits before beeping. I tried putting a 6-second delay in a repeat 10 loop, but the app wouldn't quit while in the loop. I put 10 6-second delays in a row, but that didn’t work. I put nonsense commands (set yum to 1) after each delay. That didn't work. It appears that any upcoming delay prevents Quit from working.

 

It's ridiculous to need Force Quit to quit a simple AppleScript app. Any suggestions?

Mac Pro, OS X El Capitan (10.11.5)

Posted on Sep 13, 2016 10:32 PM

Close

Q: AppleScript application won't quit

  • All replies
  • Helpful answers

  • by kevin_,

    kevin_ kevin_ Sep 14, 2016 12:12 AM in response to iTBotB
    Level 4 (1,561 points)
    Sep 14, 2016 12:12 AM in response to iTBotB

    Try the following...

     

    tell application "Finder"

         delay 60

         beep2

    end tell

     

    Also when you save it make sure that none of the options are checked in the save dialog

  • by iTBotB,

    iTBotB iTBotB Sep 15, 2016 8:10 PM in response to kevin_
    Level 1 (20 points)
    Mac OS X
    Sep 15, 2016 8:10 PM in response to kevin_

    I found some answers. Dialog boxes have a maximum time out of five minutes. However, if the display dialog command is within an application's tell… end tell block, then the dialog box times out at two minutes. This is an Apple "feature" that is difficult to work around. The easiest solution is to exit from the application with an end tell statement, write the display dialog command and code related to its result, and then, if necessary, enter another tell application statement.

     

    Delay statements have no maximum time out unless they are within an application's tell…end tell block. If so, delay also times out in two minutes.

     

    I could not find these issues documented anywhere in Apple's info for the general public. It's probably in the Developer web site, but that doesn’t help others. I own three AppleScript books. None stated the 300 second upper limit for the giving up time of a dialog box. None mentioned the problem with delay or display dialog timing out in two minutes if within an application's tell… end tell block. One book mentioned the use of the with timeout clause within a tell… end tell block. It can run for three months.

  • by kevin_,

    kevin_ kevin_ Sep 15, 2016 8:22 PM in response to iTBotB
    Level 4 (1,561 points)
    Sep 15, 2016 8:22 PM in response to iTBotB

    It sounds like your selecting "Show startup screen" when saving the script as an Application.   Make sure that you deselect this option when saving the script and it will beep twice after 60 seconds, and then quit.