Yep, read the notes several times. But, FYI, they do not replace a good example script that includes the new features. It may be obvious to some, but not all, that the examples in the notes will not run standalone, they have to be integrated into a larger script.
Many thanks for this tool and the update.
I do have a few questions that your answers would be very helpful, when you find the time:
What does start/stop animation do?
¢ I don’t see any change in behavior when I don’t use these commands.
What does “indeterminate” mean, and what is the effect of setting it to true/false?
Could you possibly give us some some control over the text size for the labels on the window/bars:
¢ window title
¢ header
¢ footer
I find the current label size to be very small, hard to read on some monitors/resolutions.
The ideal would be to let us set a point size for each.
How do we effectively use multiple progress bars?
¢ Can each bar be run/updated asynchronously?
¢ Normally one would be in some loop performing some activity when you need to update the bar.
¢ I don’t see how to do this with two activities, two bars
Can we use SKProgressBar app in two different scripts at the same time?
¢ Since your example quits the app, it would appear that other scripts might be prematurely stopped.
Thanks.
Here is an example script based on your script above, that adds some comments and tries to integrate a 2nd ProgressBar. All comments/suggestions for improvement much appreciated:
Animated GIF of ProgressBar 1.5 Script:
set iconPath to (path to applications folder as text) & "iTunes.app:Contents:Resources:iTunes.icns"
tell application "SKProgressBar"
activate
---------------------------------------------------
-- SETUP WINDOW THAT CONTAINS ALL PROGRESS BARS --
---------------------------------------------------
set title to "Demo of SKProgressBar 1.5" --> default is "SKProgressBar"
set floating to false --> default is true
set position to {100, 100} --> default is {1000, 750}, origin point is bottom left
set width to 400.0 --> default is 500.0
---------------------------------------------------
-- SETUP MAIN PROGRESS BAR --
-- (progress bar 1 by definition)
---------------------------------------------------
-- It already exists, so no need to create
set oMainBar to main bar
set currentValue to 0.0
set maxValue to 100.0
tell oMainBar --main bar
set minimum value to 0.0 --> default is 0.0
set maximum value to maxValue --> default is 100.0
set current value to currentValue --> default is 0.0
-- header / footer properties
set header to "MAIN Progress Bar" --> default is empty string
set header alignment to center --> default is left
set footer to "footer" --> default is empty string
set footer alignment to center --> default is left
-- image path can be HFS or POSIX path, default is missing value (no image)
set image path to iconPath
end tell
---------------------------------------------------
-- CREATE & SETUP PROGRESS BAR #2 --
---------------------------------------------------
set oBar2 to make new progress bar ¬
with properties {header:"TEST Progress Bar #2", header alignment:center}
move oBar2 to end of progress bars
## Don't know how to effectively use it.
---------------------------------------------------
-- DISPLAY/ACTIVATE ALL PROGRESS BARS --
---------------------------------------------------
-- This will show one window will all progress bars
## How do we use/update other ProgressBars?
set show window to true --> default is false
tell oMainBar --main bar
set indeterminate to false --> default is true
--start animation ## What is the purpose of this? I don't see any effect of using it.
repeat with nInc from currentValue to maxValue by ((maxValue - currentValue) / 10)
--increment by nInc --10.0
set current value to nInc
set footer to ((nInc as text) & " of " & maxValue as text)
delay 0.5
end repeat
--stop animation
end tell
quit ### This quits the SKProgressBar app, closing all Progress Bars
end tell
Thank you for the animated GIF and the extended script.
Both start/stop animation and indeterminate refer to the appropriate API of NSProgressIndicator
From the documentation:
start / stop animation:Starts the animation of an indeterminate progress indicator.
indeterminate:A determinate indicator displays how much of the task has been completed. An indeterminate indicator shows simply that the application is busy.
The window title is standard Cocoa window title size and cannot be changed, the size of header and footer is the same as in a Finder progress bar window, but of course it is possible to add a property (or enumeration) to control the size
AppleScript does not work asynchronously, multiple bars can be used for example in nested repeat loops. This progress bar application is a simple wrapper for one or multiple standard Cocoa NSProgressIndicator in a window and provides AppleScript control of the main properties and commands like
¢ Set minimum, maximum and current value.
¢ Set the bar to determinate or indeterminate state.
¢ Start the animation.
¢ Increment the current value.
¢ Stop the animation.
I haven’t tested that, maybe it’s possible. But it’s not required to quit the app.
Thanks for useful SKProgressBar app.
I was searching for something like that for many years.
Even Apple’s new progress property does not give you many controls. The worst omission: no way to tell progress window to close unless you quit script.
I have an issue running SKProgress Bar 1.5 or 1.6 under 10.10.11 (El Capitan). I just can’t set the position of ProgressBar. I am able to get position , but not able to set. I then tied the demo script that came with the 1.6 version and realized it does not work too (changing the 100, 100 coordinates does not produce any changes). Bar window always shows up around center–> {472, 575} on a 1440 x 900 display.
It is just annoying since important functionalities are working just fine.
Thanks Stefan for super fast reply and reaction!
Sorry to say, version 1.6.1 does not run on El Capitan [Une erreur de type -10810 est survenue.].
An error of type -10810 has happened.
Same with demo script bundled with version 1.6 dmg.
Reverting to 1.6 for now, and works as expected, except for minor flaw.
Stefan,
Thanks for the link, it was a long time since I browsed that site. Restarted Mac and did some testing. No Applications running but Script Editor, Finder, Quicktime (for video capture). Video was captured w/o sound to show script working with version 1.6, not working with 1.6.1 then working again with 1.6.
Simply said version 1.6.1 can’t launch on my Mac.
Mac OS X ElCapitan 10.11.6 [Build 15G1212] https://youtu.be/zGQctJemb2o
Jean.O.matiC
Model: MacBook Pro 15 in. Late 2008
AppleScript: 2.5
It might be that I used the wrong option to sign the application.
I created a new build (40), re-checked the deployment target, archived the app using the correct option and made an disk image like the other versions.
Stefan, I must say I am very impressed!
Everything is OK now.
I can now save position of progress bar so it re-appears as it was placed on last run of script.
Got rid of the last Carbon relict, the AppleScript point type which was mapped to old QuickDraw Point.
In Swift this required a ObjC bridge header because Carbon Point is not available in Swift.
Version 1.6.2 maps the point in the position property to NSValue.
SKProgressBar is a godsend! I had been using ProgBar as my progress bar, but it is no longer functional under Catalina. After some searching for a substitute, I came upon SKPB, and my prayers were answered!
I especially love the ability to include images in the bar. I have a question regarding that - is there any way to make the image field larger? App icons show up great in the bar, but images from JPEGs et al are often too tiny to be recognizable.
Thanks for the update, but it won’t run for me, running Script Debugger 7.0.11 (7A106) on macOS 10.14.6 (Mojave).
I get this error running your demo SKProgressbarDemo.scpt:
on this line:
set «class hDsZ» to «constant hfSZrgSZ» --> default is small
How do I fix it?
Just for reference, here is the entire script:
property currentValue : 0.0
property maxValue : 10.0
set iconPath to (path to applications folder as text) & "iTunes.app:Contents:Resources:iTunes.icns"
tell application "SKProgressBar"
activate
---------------------------------------------------
-- SETUP WINDOW THAT CONTAINS ALL PROGRESS BARS --
---------------------------------------------------
set title to "Demo of SKProgressBar 1.6" --> default is "SKProgressBar"
set floating to false --> default is true
set position to {100, 100} --> default is {1000, 750}, origin point is bottom left
set width to 400.0 --> default is 500.0
---------------------------------------------------
-- SETUP MAIN PROGRESS BAR --
-- (progress bar 1 by definition)
---------------------------------------------------
-- It already exists, so no need to create
tell main bar --main bar
set minimum value to 0.0 --> default is 0.0
set maximum value to maxValue --> default is 100.0
set current value to currentValue --> default is 0.0
-- header / footer properties
set header to "MAIN Progress Bar" --> default is empty string
set header alignment to center --> default is left
set «class hDsZ» to «constant hfSZrgSZ» --> default is small
set footer to "footer" --> default is empty string
set footer alignment to center --> default is left
set «class fTsZ» to «constant hfSZmiSZ» --> default is small
-- image path can be HFS or POSIX path, default is missing value (no image)
set image path to iconPath
end tell
---------------------------------------------------
-- CREATE & SETUP PROGRESS BAR #2 --
---------------------------------------------------
set progressBar2 to make new progress bar at after progress bar 1 with properties {header:"TEST Progress Bar #2", header alignment:center}
tell progressBar2
set maximum value to maxValue
set current value to currentValue
end tell
---------------------------------------------------
-- DISPLAY/ACTIVATE THE PROGRESS BARS --
---------------------------------------------------
-- This will show one window will all progress bars
set show window to true --> default is false
tell main bar
set indeterminate to false
start animation
end tell
repeat 10 times
my resetMainBar()
tell progressBar2
if current value is 1.0 then
set indeterminate to false
start animation
end if
end tell
repeat 10 times
tell main bar to increment by 1
delay 1
end repeat
tell progressBar2 to increment by 1
end repeat
tell main bar to stop animation
tell progressBar2 to stop animation
quit -- This quits the SKProgressBar app, closing all Progress Bars
end tell
on resetMainBar()
tell application "SKProgressBar"
tell main bar
set maximum value to maxValue
set current value to currentValue
end tell
end tell
end resetMainBar
Hi Stefan,
trying to use SKProgressBar1.9 to display several progress bars about some nested processes for my scripts, I encounter a problem as soon as I try to add a 3rd progress bar. Working with a copy of your demo script, I get an AppleScript Execution Error saying “Erreur dans SKProgressBar : Le gestionnaire AppleEvent a échoué.” and a -10000 error code (errAEEventFailed) as soon as I reach the extra line
set progressBar3 to make new progress bar at after progress bar 2 with properties {header:"EXTRA Progress Bar #3"}
I’ve added after ‘CREATE & SETUP PROGRESS BAR #2’ block and before ‘DISPLAY/ACTIVATE THE PROGRESS BARS’ one.
Did I misunderstand that number of progress bars was potentially unlimited, and if not, do you have any idea of what is going wrong?
Thanks a lot.