Re: Run Script until User Action
Re: Run Script until User Action
- Subject: Re: Run Script until User Action
- From: "Stockly, Ed" <email@hidden>
- Date: Tue, 21 Mar 2006 12:14:48 -0800
>>>>I've got a simple applescript that performs some timed actions over a period of 20 minutes or so. Sometimes, though, I need to be able to stop it. Since it doesn't have any menus, I can't quit. It doesn't show up as a process that I can kill. Could I write a dialog box that would display when the script begins and that would stop the script if I click it's button? How would I do that? I already know how to create the dialog itself, just not make it stop the script.
Dialogs aren't designed to be used that way. Your script will stop running until the dialog is answered. It would be possible to launch a second applet that only displays a dialog and sends an appleEvent to the first if the user clicks quit.
I had a similar situation and I chose to use system events and the capslock key. When the script launches it gets the position of the capslock key. At several points during execution (following distilling a file, for example) it checks to see if the capslock position has changed and if it has displays a dialog asking if the user wants to quit. If the user doesn't want to quit (of if the dialog gives up after 10 mins) the script remembers the new position of the caps lock key and continues. If the script is not doing time consuming tasks that you want to finish gracefully before an interrupt, you could the same thing with any key (esc, for example). If needed I can post the handlers that do this.
Another option to consider would be simply bringing the script to the front and command-cancel, and then trapping the error in the script.
HTH,
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden