Sunday, July 23, 2017

#1 2011-06-29 04:06:55 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

SKProgressBar 1.0, a fully scriptable progress bar

Actually this is a topic for ScriptBuilders, but unfortunately ScriptBuilders is still broken.

Inspired by Bruce Phillips' BP Progress Bar (Thanks Bruce) I wrote a fully scriptable Cocoa application for the same purpose to be able to display a progress bar from plain AppleScript

You can download it here: SKProgressBar 1.0,
it runs on an Intel Mac with 10.5 or higher

This code is also included in the .dmg

Applescript:


(*
   SKProgressBar is a simple but fully scriptable Cocoa application
   including a progress bar, two status text fields (header and footer)
   and an image view to display an icon.
   
   This sample script covers all commands and properties
   
   Read the AppleScript dictionary for further information
   
   The application can be used faceless by setting the key LSUIElement to 1 in info.plist
   
   System Requirements: Intel Mac with Mac OS 10.5 or higher
   
   Inspired by Bruce Phillips' BP Progress Bar on macscripter.net
   
   SKProgressBar is free for non-commercial use,
   see the License Agreement in the README file or the About window.

   Â© 2011 Stefan Klieme
*)


set iconPath to (path to applications folder as text) & "iTunes.app:Contents:Resources:iTunes.icns"

tell application "SKProgressBar"
   activate
   
   -- main window properties
   set floating to false --> default is true
   set position to {100, 100} --> default is {1000, 750}, origin point is bottom left
   set width to 600.0 --> default is 500.0
   set title to "myGreatTitle" --> default is "SKProgressBar"
   
   -- header / footer properties
   set header to "header" --> default is empty string
   set header alignment to right --> 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
   
   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 30.0 --> default is 0.0
   end tell
   
   set show window to true --> default is false
   tell progress bar
       set indeterminate to false --> default is true
       
       start animation
       repeat 6 times
           increment by 10.0
           delay 1
       end repeat
       stop animation
       
   end tell
   quit
end tell

Last edited by StefanK (2011-06-29 04:07:12 pm)


regards

Stefan

Offline

 

#2 2011-07-05 11:49:07 pm

lemuralex13
Member
Registered: 2011-06-22
Posts: 77

Re: SKProgressBar 1.0, a fully scriptable progress bar

Nice, I've been looking for one for a while big_smile


Awesome ----> Alex | xelA <---- emosewA

Offline

 

#3 2011-07-06 12:18:31 am

lemuralex13
Member
Registered: 2011-06-22
Posts: 77

Re: SKProgressBar 1.0, a fully scriptable progress bar

BTW, do you know how I could change the footer/header while the animation is playing? Thanks


Awesome ----> Alex | xelA <---- emosewA

Offline

 

#4 2011-07-06 01:58:10 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

Just set it, the animation works asynchronously


regards

Stefan

Offline

 

#5 2011-07-06 09:32:36 am

lemuralex13
Member
Registered: 2011-06-22
Posts: 77

Re: SKProgressBar 1.0, a fully scriptable progress bar

Ok, I accidently had it all in a progress bar tell, nvm, its good, thanks


Awesome ----> Alex | xelA <---- emosewA

Offline

 

#6 2011-08-12 10:49:34 am

thewaytoapplescript
Member
Registered: 2011-05-30
Posts: 144

Re: SKProgressBar 1.0, a fully scriptable progress bar

StefanK,

Nice work! Everything works great on Lion, except for one thing...

When the header and footer alinements are set to center, they actually go to the far right. When they are set to right, they are in the center.

Just wanted to let you know!


It depends on whether Apple wants to sell mass-market toasters, or computers; and Lion moved us a little bit in the direction of toasters. -partron22

Offline

 

#7 2013-02-13 04:28:18 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

Update: Version 1.0.1

Release Notes:

• center / right alignment bug fixed
• code signed

Download: SKProgressBar 1.0.1


regards

Stefan

Offline

 

#8 2013-02-13 07:29:56 pm

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4658

Re: SKProgressBar 1.0, a fully scriptable progress bar

For me in OS X 10.8.2, the script hangs with the new version.

Applescript:


tell progress bar
       set indeterminate to false --> default is true
       
       Â«event PrBrStMn»
       repeat 6 times
           Â«event PrBrIcRm» given «class bYVl»:10.0
           delay 1
       end repeat
       Â«event PrBrSpMn»
       
   end tell


iMac running OS X 10.11.6

Offline

 

#9 2013-02-14 12:58:26 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

the cryptic raw events should compile as

start animation
increment by
stop animation

Of course I tested the application. It works fine on my machine (also 10.8.2).
Have you deleted the 1.0 version?


regards

Stefan

Offline

 

#10 2013-02-14 05:22:36 am

flex20
Member
From:: Sydney, Australia
Registered: 2010-08-24
Posts: 202

Re: SKProgressBar 1.0, a fully scriptable progress bar

Hi Stefan,
I can confirm Adam's post about the new version.  It hangs on or after "set indeterminate to false" by inserting this in the script:

Applescript:

   tell progress bar
       activate
       set indeterminate to false
       Â«event PrBrStMn» —> this
       tell current application
           -- do shell script ...
       end tell
       repeat 10 times
           Â«event PrBrIcRm» given «class bYVl»:10.0 —> this
           delay 1
       end repeat
       Â«event PrBrSpMn» —> this
   end tell

and these are the script replies:

Applescript:

tell application "SKProgressBar"
   set image path to "path:to:me:Contents:Resources:my.icns"
   set minimum value of progress bar to 0.0
   set maximum value of progress bar to 100.0
   set current value of progress bar to 0.0
   set show window to true
   activate
   set indeterminate of progress bar to false
   Â«event PrBrStMn» progress bar
       --> error number -1708
Result:
error "SKProgressBar got an error: progress bar doesn’t understand the «event PrBrStMn» message." number -1708 from progress bar

I too have 10.8.2 and I deleted all copies of the v1.0 of SKProgressBar.app, except the Time Machine.

Offline

 

#11 2013-02-14 05:57:16 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4335

Re: SKProgressBar 1.0, a fully scriptable progress bar

For me, in Snow Leopard, the script compiled correctly but, when run, hung for several seconds until the system's "application downloaded from the Internet" warning appeared. Since that was OK'd, everything seems to work fine.

PS. If I substitute Adam's and flex20's raw codes for the keywords, they don't compile as keywords in the AppleScript Editor window and the script suffers the same problems when run. Maybe there are terminology clashes on Adam's and flex20's systems causing miscompilations?

PPS. If I save the correctly compiled script, close AppleScript Editor, zap SKProgressBar from my startup disk, and reopen the script in AppleScript Editor, the raw codes are different from those reported by Adam and flex20:

Applescript:

   tell «class cRpB»
       set «class iDtM» to false --> default is true
       
       Â«event pGbRStMn»
       repeat 6 times
           Â«event pGbRIcRm» given «class bYVl»:10.0
           delay 1
       end repeat
       Â«event pGbRSpMn»
       
   end tell

PPPS. What's the betting Script Debugger's involved somehow?  wink

Last edited by Nigel Garvey (2013-02-14 06:41:25 am)


NG

Offline

 

#12 2013-02-14 07:21:29 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5046

Re: SKProgressBar 1.0, a fully scriptable progress bar

The problem seems to be that Stefan has changed the four-letter codes between versions, and flex20 and Adam must have the old version still on their systems.

In particular, increment has changed from PrBrIcRm to pGbRIcRm, start animation from PrBrStMn to pGbRStMn, and stop animation from PrBrSpMn to pGbRSpMn.

I'm not sure why he made the change, but the solution is to remove the previous version, and convince ASE to remove it from its cache.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#13 2013-02-14 09:31:41 am

flex20
Member
From:: Sydney, Australia
Registered: 2010-08-24
Posts: 202

Re: SKProgressBar 1.0, a fully scriptable progress bar

Shane Stanley wrote:

and flex20 and Adam must have the old version still on their systems.


Hi Shane,
I have actually deleted what I think were all traces of v1.0, except for whatever is in the Time Machine.  But just to make sure after your post, I booted on my clean volume I maintain for just such testing.

Then, I ejected my main volume, as well as a scrap volume I have, to make sure that nothing can be accessed on them.

Finally I run my script bundle with the SKProgressBar v1.0.1 in it.  It crashed at the same place with the same message.
So, I really don't think that the cause of the crash has anything to do with a clash of versions.

I also want to point out that I have now two scripts with integrated SKProgressBar v1.0 (I only discovered this app a few days ago) and they work perfectly on my 2010 iMac with 10.8.2.

Cheers, Chris


Filed under: SKProgressBar

Offline

 

#14 2013-02-14 11:57:51 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

Sorry about the confusion.

I really can't remember why I changed the four-character codes.
There were some inactive NSScriptCommand classes in the project, so I guess
I changed the respective commands from verb-first to object-first (Shane you know what I mean wink )
To be consistent the first 4-character codes have been changed to the parent class.

Last edited by StefanK (2013-02-14 05:06:51 pm)


regards

Stefan

Offline

 

#15 2013-02-14 02:48:05 pm

flex20
Member
From:: Sydney, Australia
Registered: 2010-08-24
Posts: 202

Re: SKProgressBar 1.0, a fully scriptable progress bar

Hi Stefan,
Will you now release/post a new version?  I checked v1.0.1 you posted at #7 above, but it is still yesterday's version.
It's no rush really, because v1.0 is working just fine.
Regards,
Chris

Offline

 

#16 2013-02-14 05:05:42 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5046

Re: SKProgressBar 1.0, a fully scriptable progress bar

flex20 wrote:

Finally I run my script bundle with the SKProgressBar v1.0.1 in it.  It crashed at the same place with the same message.


If the message contains "PrBrStMn", then it's using the old terminology. It may be just ASE caching it (this is another good reason to use Script Debugger). But whatever, the only place PrBrStMn is used is in the old version.

Try copying the code in Nigel's message and see what it compiles to.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#17 2013-02-14 05:07:16 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5046

Re: SKProgressBar 1.0, a fully scriptable progress bar

StefanK wrote:

I changed the respective commands from verb-first to object-first


Ah, I was wondering why you did it wink


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#18 2013-02-14 05:54:01 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4335

Re: SKProgressBar 1.0, a fully scriptable progress bar

flex20 wrote:

I have actually deleted what I think were all traces of v1.0, except for whatever is in the Time Machine.  But just to make sure after your post, I booted on my clean volume I maintain for just such testing.

Then, I ejected my main volume, as well as a scrap volume I have, to make sure that nothing can be accessed on them.

Finally I run my script bundle with the SKProgressBar v1.0.1 in it.  It crashed at the same place with the same message.


Did you recompile the script against the new version, making sure the source code in your editor contained all the original keywords?


NG

Offline

 

#19 2013-02-15 05:01:02 am

flex20
Member
From:: Sydney, Australia
Registered: 2010-08-24
Posts: 202

Re: SKProgressBar 1.0, a fully scriptable progress bar

Shane Stanley wrote:

If the message contains "PrBrStMn", then it's using the old terminology. It may be just ASE caching it (this is another good reason to use Script Debugger). But whatever, the only place PrBrStMn is used is in the old version.


Nigel Garvey wrote:

Did you recompile the script against the new version, making sure the source code in your editor contained all the original keywords?


OK, this is what I just did again:
* restored my clean test volume from a "virgin" 10.8.2 disk image with my basic configuration and disabled Spotlight;
* restarted from it and then ejected my main volume to isolate the clean test volume;
* opened a new blank script and copy/pasted the code from my original script and then saved the new script as a bundle with a new name;
* navigated to it's Resources folder and copied the SKProgressBar.app v1.0.1 to it;
* compiled and saved it; (no app v1.0 or a script containing it, were in sight or ever run on that clean volume)
* run it.
It crashed again at the same place, with the same raw codes but, slightly changed script replies:

Applescript:

tell application "SKProgressBar"
   tell progress bar
       activate
       set indeterminate to false
       Â«event PrBrStMn»
       tell current application
           -- do shell script ...
       end tell
       repeat 10 times
           Â«event PrBrIcRm» given «class bYVl»:10.0
           delay 1
       end repeat
       Â«event PrBrSpMn»
   end tell
   quit --> error number 0
end tell
(*Replies
tell application "SKProgressBar"
   activate
   set indeterminate of progress bar to false
   Â«event PrBrStMn» progress bar
       --> error number -1708
Result:
error "SKProgressBar got an error: progress bar doesn’t understand the «event PrBrStMn» message." number -1708 from progress bar*)

While the script was frozen and SKProgressBar was still running, I checked that its version was indeed 1.0.1.
So, I think that shows that v1.0.1 in a clean script, running on a clean volume is still crashing with a reproducible error.

Cheers, Chris

Offline

 

#20 2013-02-15 05:04:29 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

please replace

«event PrBrStMn» with start animation
«event PrBrIcRm» given «class bYVl»:10.0 with increment by 10
«event PrBrSpMn» with stop animation


regards

Stefan

Offline

 

#21 2013-02-15 05:17:07 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5046

Re: SKProgressBar 1.0, a fully scriptable progress bar

flex20 wrote:

copy/pasted the code from my original script


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).


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#22 2013-02-15 06:12:53 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4335

Re: SKProgressBar 1.0, a fully scriptable progress bar

StefanK wrote:

please replace

«event PrBrStMn» with start animation
«event PrBrIcRm» given «class bYVl»:10.0 with increment by 10
«event PrBrSpMn» with stop animation


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 (old) 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.


NG

Offline

 

#23 2013-02-15 06:35:27 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

Hi Nigel,

thanks for the suggestion, I did that, same link


regards

Stefan

Offline

 

#24 2013-02-15 09:44:58 am

flex20
Member
From:: Sydney, Australia
Registered: 2010-08-24
Posts: 202

Re: SKProgressBar 1.0, a fully scriptable progress bar

Shane Stanley wrote:

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 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

Offline

 

#25 2013-02-15 05:16:12 pm

flex20
Member
From:: Sydney, Australia
Registered: 2010-08-24
Posts: 202

Re: SKProgressBar 1.0, a fully scriptable progress bar

StefanK wrote:

I did that, same link


Many thanks Stefan,
The new version 1.0.1(3) works perfectly now in 10.8.2 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

Nigel Garvey wrote:

Anyone seeing start animation (old) ... could simply delete the (old) and recompile the script to get the new token.


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

Cheers,
Chris

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)