I have a script that (barebones) does the following:
repeat
tell application "System Events" to set myApp to first process where it is frontmost
tell application “MyAppGoesHere”
activate
-- Magic Happens Here
end tell
tell application "System Events" to set frontmost of myApp to true
delay 600
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?