• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Exiting an app with an infinite loop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exiting an app with an infinite loop?


  • Subject: Re: Exiting an app with an infinite loop?
  • From: "Stockly, Ed" <email@hidden>
  • Date: Mon, 29 Aug 2016 17:47:04 +0000
  • Thread-topic: Exiting an app with an infinite loop?

Does your applescript applet have a quit handler?

On quit
 Continue quit
End

If so, another app could do:

Tell application “MyAppGoesHere” to quit

If that doesn't work, you may try using that with an a quitting error handler:

Try

—the idle handler or the part of the script inside the infinite loop
On error 
Tell me to quit
End

Then you could bring your applet to the front and hit command-period to force an error. (if you have a complex script with lots of error handlers, the error trapping and passing may get tricky).

 (your milage may vary)




From: <applescript-users-bounces+ed.stockly=email@hidden> on behalf of "@lbutlr" <email@hidden>
Date: Sunday, August 28, 2016 at 2:58 PM
To: AppleScript Digest <email@hidden>
Subject: Exiting an app with an infinite loop?

I have a script that (barebones) does the following:

repeat
tellapplication "System Events" to set myAppto first processwhere it is frontmost
tellapplication “MyAppGoesHere”
activate
-- Magic Happens Here
end tell
tellapplication "System Events" to set frontmostof myAppto true
delay600
end repeat

Which works fine. The only issue is that I cannot quit the app when I no longer need it to run. It is saved as an Application and I can bring the app to the foreground and I get the menu bar and I select quit and… nothing.

I have to force quit the applescript app.

Now, sometimes I have this app running for a couple of hours, and sometimes I have it running for a couple of days, so setting the repeat to a specific number or times is not workable. I tried using a display dialog with a short time out so I could press cancel, those this meant I may have to wait 10 minutes for the dialog to reappear.

display dialog “Continue?” giving up after 2

But that would often cause the script to time out with the dialog open.

(I am running on 10.12 developer beta currently, but I am pretty sure this is the same behavior I had in 10.11.3)

Ideas?


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Exiting an app with an infinite loop? (From: "@lbutlr" <email@hidden>)

  • Prev by Date: Re: Anyone use Macterm
  • Next by Date: Re: "where its" vs "whose"
  • Previous by thread: Re: Exiting an app with an infinite loop?
  • Next by thread: Determining accessibility of Applescript App?
  • Index(es):
    • Date
    • Thread