SKProgressBar 1.0, a fully scriptable progress bar

That’s never going to solve the problem if the code you’re pasting contains the old codes. Either use the new codes, or just rewrite the commands to use the English commands (set current value, increment, etc).

Hi Stefan.

The changes are rather disastrous, since they break every script compiled against the previous version(s) of your app ” which is inconvenient for all your existing users, not just those who don’t know about compiled tokens.

In the past, when Apple or anyone wanted to change an event or class code, they might give the old code a new keyword ” say start animation (old) ” and allow it still to work. That way, existing scripts wouldn’t break and new ones would get the new token for the original keyword. Anyone seeing start animation (old) when opening an older script in their editor could simply delete the b[/b] and recompile the script to get the new token. I don’t know how feasible this is nowadays, but something like it should be considered.

Hi Nigel,

thanks for the suggestion, I did that, same link

Hi Shane,
What I copied was the absolute original code from v1.0 of my script, I had been using before I even heard of this progress bar app. Then, I modified my original code, by copy & pasting from Stefan’s script at the top of this page, so as to enclose the action I wanted to attach the bar to (i.e. the action is inserted between ‘start animation’ and the increment repeat block).

Unless, I really misunderstand what you are saying (and that’s a very distinct possibility), I think that what I’ve done is in fact equivalent to retyping the whole code. Please comment if you think I’m wrong,

Cheers, Chris

Many thanks Stefan,
The new version 1.0.1(3) works perfectly now in 10.8.2 :slight_smile:
May I suggest to update the link at #1 to always point to the latest version, to make it easier to find.

I had to update 13 instances of SKPB 1.0 code, but hey, the end result is great :cool:

Not so great was that I was about half through updates, busily retyping over the three commands, before I finally noticed Nigel’s suggestion :stuck_out_tongue:

Cheers,
Chris

No, that sounds right. But the old app’s terminology was being accessed somewhere…

At some point Stefan, I’m hoping there will be a link to disk image download with the latest application version, the read me document and a sample script that works without any editorial repairs. Without that, you’ll be deluged with emails when it doesn’t work for new users.

For now, the best bet is to go to post #1 and download SKProgressBar 1.0 which after unpacking is a dmg. Remove the Readme and Script files, but not the application and eject the dmg.

Then go to post #7 and download SKProgressBar 1.0.1. Now you can compile the script. In the script, you may find the word (old) in several places. Remove those and recompile. Now you’re good to go.

I know this is kinda old, but I just wanted to say thanks. This is awesome. I added it to an ancient script that I am updating and it saved me a ton of work.

I update the app to version 1.1 . It uses now ARC and is compatible from 10.7 to 10.11

SKProgressBar 1.1

Nice Stefan and timing couldn’t be better :cool:. I saw in some post people in doubt of using SKProgressIndicator solely based on the fact it hasn’t been updated in a while.

Actually that’s the reason why I updated it :wink:

Thanks for the update. It is very good to know that it is compatible with Yosemite and El Capitan.
Do you expect it to be compatible beyond 10.11?

May I suggest that you include the following in your zip file:

  • The demo script that you have at the top of this thread.
  • A demo that works with other apps
  • A ReadME that provides basic install and usage instructions

If I am going to use this, and distribute with my scripts, I don’t want to point the recipients to this thread, which could raise a lot of questions and cause confusion among users who just use AppleScripts, as opposed to develop them.

Thanks.

I’m seeing a number of commands in the scripting dictionary with “(old)”. There was some discussion above about removing these. So should these “(old)” commands be avoided?

Yes.

Stefan did not only changed names in updates but also AE code. So when an old script is re-opened with script editor and SKProgresssIndicator is updated meanwhile the user doesn’t see raw event code.

If you’ve never used SKProgressBar before the issue doesn’t affect you at all. just use the “new” commands.

Hi Stefan, I’ve been using your progress bar for a few years on a file transfer app I wrote. It’s always worked perfectly for me, so thank you for that. I just updated to the latest version and after removing all the (old) tags it still functions perfectly. I have a question though. Is it possible to implement two progress bars in the same window? For instance, one bar to show the progress of a specific file, and another to show the progress of the overall transfer? Currently I have it running so that it counts every file in a list, divides by 100, and then passes that onto the progress bar. That part works great. But since the files I’m transferring range anywhere from 1MB to 4GB, it would be nice if each file also had a progress indicator. I’ve included my code below if that helps.



set chooseString to "Select a folder containing images to be sorted"
set folderPath to (choose folder with prompt chooseString)
set toPath to "2TB Seagate:Photos:"
set moviesPath to "2TB Seagate:Movies:"
set photoList to {"CR2", "JPG"}
set movieList to {"MOV", "MP4", "AVI"}
set iconPath to "960GB SSD:System:Library:CoreServices:Finder.app:Contents:Resources:Finder.icns"

tell application "Finder"
	set FileList to every file of folderPath
	set fileCount to count of FileList
	set filePercent to 100 / fileCount
	my progressBar(fileCount, iconPath)
end tell

with timeout of 3600 seconds
	repeat with aFile in FileList
		set headertext to aFile as text
		my progressStart(fileCount, headertext)
		my progressHeader
		tell aFile to set {nameExtension, creationDate, FilePath} to {name extension, creation date, it as text}
		tell creationDate to set folderDate to (year as text) & "_" & my pad(its month as integer) & "_" & my pad(day) & "/" -- AppleScript coerces to text implicitly
		if nameExtension is in photoList then
			do shell script "ditto " & quoted form of POSIX path of FilePath & space & quoted form of (POSIX path of toPath & folderDate)
			my progressIncrement(filePercent)
		else if nameExtension is in movieList then
			do shell script "ditto " & quoted form of POSIX path of FilePath & space & quoted form of (POSIX path of moviesPath & folderDate)
			my progressIncrement(filePercent)
		end if
	end repeat
	my progressStop
	tell application "SKProgressBar"
		quit
	end tell
end timeout

display notification ((count of FileList) as string) & " files were transferred." sound name "Glass" with title "Camera Transfer App"
delay 1
on pad(integerValue)
	return text -2 thru -1 of ("00" & integerValue as text)
end pad

on progressBar(fileCount, iconPath)
	tell application "SKProgressBar"
		activate
		-- main window properties
		set floating to true --> default is true
		set position to {400, 300} --> default is {1000, 750}, origin point is bottom left
		set width to 600.0 --> default is 500.0
		set title to "File Transfer" --> default is "SKProgressBar"
		set image path to iconPath
		tell progress bar
			set minimum value to 0.0 --> default is 0.0
			set maximum value to 100.0 -->  default is 100.0
			set current value to 0.0 --> default is 0.0
			set indeterminate to false --> default is true
		end tell
		
		set show window to true --> default is false
	end tell
end progressBar

on progressIncrement(filePercent)
	tell application "SKProgressBar"
		tell progress bar
			increment by filePercent
		end tell
	end tell
end progressIncrement

on progressStart(fileCount, headertext)
	tell application "SKProgressBar"
		my progressHeader(headertext)
		tell progress bar
			start animation
		end tell
	end tell
end progressStart

on progressStop()
	tell application "SKProgressBar"
		tell progress bar
			stop animation
		end tell
		quit
	end tell
end progressStop

on progressHeader(headertext)
	tell application "SKProgressBar"
		set header to headertext
	end tell
end progressHeader


Of course it’s possible, but this requires extra work to

¢ Implement a scripting element bars to allow the user to add and remove bars.
¢ Implement a table view for the UI.
¢ Move the header, footer, imagePath etc. properties from the application class to the bar class

Nevertheless this is a very interesting suggestion. I will think about it.
Maybe a good exercise to port the project to Swift…

Thanks. At least I know it’s not possible with the current version so I can stop trying out stupid things. Cheers again on a great little program.

[ANN] SKProgressBar 1.5

Completely refactored in Swift, therefore requirement is Mac OS 10.9 Mavericks or later.

Main improvement: Multiple progress bars in a single window.

Changes :

  • Add: New element progress bars, the items are referenced by index.

  • Add: Implementation of the AppleScript commands make, move and delete.

    Example:

	set progressBar2 to make new progress bar with properties {header:"File Transfer", header alignment:center}
	move progress bar 2 to end of progress bars
	delete progress bar 3

  • Add: A property main bar which represents always the top bar (equivalent to progress bar 1).

    Example:

	tell main bar to set footer to "Done"
  • Add: A property quit delay to automatically quit the app on idle after the specified delay in seconds (default is 300). A value of 0 will not cause the app to quit.

Change: The properties header, header alignment, footer, footer alignment and image path have beed moved to the progress bar class.

  • Change: The type of the property width has been changed from real (Double) to integer (NSInteger)
  • Change: The type of the property image path has been changed from text (NSString) to file (NSURL), the benefit is it considers HFS paths, POSIX paths and alias specifiers.
  • Change: The application runs faceless by default.

Download: SKProgressBar 1.5

Awesome. I’ve been out of town so I just saw this. Haven’t had a chance to play with it yet but I’m impressed at how quickly you got it done. If I knew you in real life I’d buy you a beer.