AppleScript progress (Yosemite)

AppleScript’s new built-in progress capabilities are awesome but I just have a couple of questions which I haven’t managed to figure out:

  1. Can I intercept or ignore a click from the ‘stop’ button? I found that I can use a try statement to sort of catch the “user cancelled” error that gets thrown, but as soon as the “on error” clause finishes the script always terminates.

  2. AppleScripts run from the Script menu can show progress in the Automation menu. Is there any way to take advantage of this when running AppleScript within an Automator workflow? Automator itself doesn’t appear to offer any control of progress.

It looks to me like you can catch it with a quit handler – I’m guessing it just tells the app to quit. Cleaning up from a quit handler is probably going to be a bit messy, but it’s better than nothing.

A quick test suggests not.

This doesn’t appear to work. Still exits after running the quit handler, or in the case of stay-open the quit handler doesn’t even get called (the app does stay open, it just aborts whatever it was doing). I guess the answer to this one is also no.

Yes, it looks like it’s posting continuous errors.

try
	try
		try
			try
				try
					set progress total steps to 10
					repeat with i from 1 to 10
						set progress description to "Processing " & i & " of " & 10
						repeat 10 times
							do shell script "sleep .1"
						end repeat
						set progress completed steps to i
					end repeat
				on error errMess
					display dialog "I'm doing clean-up here"
				end try
			on error errMess
				display dialog "I'm doing clean-up here 2"
			end try
		on error errMess
			display dialog "I'm doing clean-up here 3"
		end try
	on error errMess
		display dialog "I'm doing clean-up here 4"
	end try
on error errMess
	display dialog "I'm doing clean-up here 5"
end try

Hi,

Maybe it was meant to be that the total steps shouldn’t be reached. This stay open app just goes to 19 and quits:

on run
	set progress description to "processing ..."
	set progress total steps to 20
	repeat with i from 0 to 18 by 2
		set progress completed steps to i
		delay 1
	end repeat
	set progress description to "cleaning up ..."
	delay 2
	quit
end run

on quit
	set progress completed steps to 19
	continue quit
end quit

gl,
kel

This one is a little better:

on run
	set progress description to "processing ..."
	set progress total steps to 100
	repeat with i from 0 to 50
		set progress completed steps to i
		delay 0.2
	end repeat
	set progress description to "cleaning up ..."
	delay 2
	quit
end run

on quit
	set progress completed steps to 99
	delay 0.5
	continue quit
end quit

is there a way to close one progress bar and start another one when the first task is complete?