| |
| | |

Apple Phoon Forum

 Forgot password?
View: 627|Reply: 2

Applescript app won't quit

[Copy link]

Post time: 2014-01-16 19:04:04 |Show all posts
Using OS X Mountain Lion
I need a little help. I have written an AppleScript app that "touches" one of my external drives every 55 seconds to keep it from spinning down. However, this app won't quit when I depress command-Q ... even though I have included an "on quit" handler. Can anyone suggest what I need to change to have this app respond properly to command-Q? Here's the script:
with timeout of 99999999 seconds

tell application "Finder"



do shell script "touch -a /Volumes/TimeMachine/.TemporaryItems"

delay 55

end repeat

end tell

end timeout
on quit

continue quit

end quit
        iMac (27-inch, Late 2012), OS X Mountain Lion (10.8.3)

Use magic Report

Post time: 2014-01-16 22:22:11 |Show all posts
Thanks. Your solution works like a charm.

Use magic Report

Post time: 2014-01-16 20:29:35 |Show all posts
AppleScript is not multi-threaded, so the application will never get the quit message because the repeat loop never finishes. Sitting in a continual repeat loop is not the way to go since it blocks the user interface - instead, resave your application with the option to stay open, and use the idle handler (note that the Finder is not needed for the do shell script command):
on idle
do shell script "touch -a /Volumes/TimeMachine/.TemporaryItems"
return 55
end idle

Use magic Report

You have to log in before you can reply Login | Register

Archive| Apple Phoon

2021-04-18 07:22 GMT-8 , Processed in 0.070048 sec., 27 queries .

Powered by Discuz! 7.2

Release 20121101, © 2001-2021

To Top