Running Window...

A few of the scripts that I have created take 15+ seconds to run depending on the size of the database that they are accessing…as such I would like to create a window that displays “Script running…” ideally with the dots flashing while the script is in fact running.

As I am new to AppleScript I do not know how to do this nor can I find any related information on the net and would thus appreciate any information / insight into this [i.e. this can be done as follows, this can be done by taking at …, this can not be done, etc.].

Thanks in advance as I appreciate all the help!

Basically, no: you cannot display a dialog from a running script, and have the script continue while the dialog stays up.
Blinking dots, or any change at all, cannot be displayed, unless you close and reopen the dialog - you’d really blink the dialog.

That said, there’s another approach here: you run a dummy script application from the working script, and quit it when the main script is done.
While the script runs there will be an icon in the Dock, telling you your script is running.

Also, there are ways to display a progress bar, but I’ve never used them.

Edit:

Check out display dialog and display alert. They’re in Standard Additions.
In recent OS versions there’s also display notification.

If you’re running Yosemite, you can use the progress properties. For example:

set time1 to current date
set progress total steps to 10
repeat with i from 1 to 10
	set progress description to "Processing " & (i - 1) & " of " & 10
	do shell script "sleep 0.5"
	set progress completed steps to i
end repeat
display dialog ((current date) - time1) as text

In an applet, it appears as a dialog with a progress bar. The downside is that the Stop button does just that, with no chance to clean up.

Appreciate the response and will give it go should the code in the immediately preceding post not work as it is closer to what I am looking for…thanks…

Shane:

Fantastic, I am going to give it go but I do have to follow ups:

  1. How does the determine the percent of the script / work that is completed or is that a built in functionality?

  2. is there a way to get it to shut down once an event happens…for example, in the two or three scripts that you have helped with the results are output to an Excel spreadsheet meaning it would be nice to have the “progress dialog” shut down once the spreadsheet appears because obviously the script is running.

Thx,

Joel

AppleScript calculates it, based on progress total steps and progress completed steps.

No. It stays up as long as the script is running.

Shane:

Appreciate the response, very helpful.

I tried using the code and while it is better than nothing as it does inform the uninitiated user that a script is being run it is far from perfect…I tried entering at the very top of my script and it ran without any problems but its internal “step processing” is flawed [i.e. it said it had processed 8 out of 10 steps before the first input dialog box appeared!]…I then tried running it within a tell block thinking this could / would solve the above noted problem but it crapped out with an error message that it could not set “progress total steps”.

So – apologies for keeping this discussion going – I have two more follow ups:

  1. Can the block of code be placed other than at the very top of the script to avoid the “step processing problem” I highlighted above and, if yes, what do I need to do to make that work [i.e. to avoid the error message I received when I placed it within a tell block]?

  2. What other – if any – tips and tricks do you ahem in using this approach?

Thanks,

Joel

They are properties of AppleScript, so if you want to set them within a tell block, use “set AppleScript’s progress completed steps to …”.

Shane:

Thanks for this…I modified the relevant section of the script code to read as noted below and it would like a charm…appreciate you teaching me yet another new thing!


-- Create a dialog box to inform the user that the script is running
	set time1 to current date
	set AppleScript's progress completed steps to 1
	repeat with i from 2 to 10
		set AppleScript's progress description to "Processing " & (i - 1) & " of " & 10
		do shell script "sleep 0.5"
		set AppleScript's progress completed steps to i
	end repeat

Joel