Friday, December 2, 2016

#26 2013-02-15 04:37:27 pm

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

flex20 wrote:

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

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


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

Offline

 

#27 2013-02-15 05:39:08 pm

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

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.


iMac running OS X 10.11.6

Offline

 

#28 2013-10-16 09:45:30 am

jswingchun
Member
Registered: 2005-07-18
Posts: 26

Re: SKProgressBar 1.0, a fully scriptable progress bar

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.

Offline

 

#29 2016-01-15 04:06:38 am

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

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

SKProgressBar 1.1


regards

Stefan

Offline

 

#30 2016-01-15 04:39:42 am

DJ Bazzie Wazzie
Member
From: the Netherlands
Registered: 2004-10-20
Posts: 2543

Re: SKProgressBar 1.0, a fully scriptable progress bar

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.

Last edited by DJ Bazzie Wazzie (2016-01-15 05:43:59 am)

Offline

 

#31 2016-01-15 04:41:13 am

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

DJ Bazzie Wazzie wrote:

timing couldn't better. 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


regards

Stefan

Offline

 

#32 2016-01-16 07:15:04 pm

JMichaelTX
Member
From: Houston, TX (The Woodlands)
Registered: 2014-07-12
Posts: 125

Re: SKProgressBar 1.0, a fully scriptable progress bar

StefanK wrote:

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

SKProgressBar 1.1

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.


MBP-15R, Early 2013 (& others)
Mac OS X Yosemite (10.10.5)

Offline

 

#33 2016-01-16 07:31:12 pm

JMichaelTX
Member
From: Houston, TX (The Woodlands)
Registered: 2014-07-12
Posts: 125

Re: SKProgressBar 1.0, a fully scriptable progress bar

StefanK wrote:

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

SKProgressBar 1.1

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?

SKProgressBar 1.1 Scripting Dictionary wrote:

increment(old) method : Advances the progress bar of a determinate progress indicator by the specified amount.
increment(old) Progressbar : the progress bar passed to the command
by: real : the specified amount.
startAnimation(old) method : Starts the animation.
startAnimation(old) Progressbar : the progress bar passed to the command
stopAnimation(old) method : Stops the animation.
stopAnimation(old) Progressbar : the progress bar passed to the command


MBP-15R, Early 2013 (& others)
Mac OS X Yosemite (10.10.5)

Offline

 

#34 2016-01-16 08:58:09 pm

DJ Bazzie Wazzie
Member
From: the Netherlands
Registered: 2004-10-20
Posts: 2543

Re: SKProgressBar 1.0, a fully scriptable progress bar

JMichaelTX wrote:

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.

Offline

 

#35 2016-01-17 02:17:15 am

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

JMichaelTX wrote:

There was some discussion above about removing these.  So should these "(old)" commands be avoided?

If you've never used SKProgressBar before the issue doesn't affect you at all. just use the "new" commands.

Last edited by StefanK (2016-01-17 02:18:18 am)


regards

Stefan

Offline

 

#36 2016-05-12 02:40:12 am

relishgargler
Member
From: Newport, MN
Registered: 2010-07-21
Posts: 84
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

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.

Applescript:



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

Offline

 

#37 2016-05-12 11:55:47 am

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

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


regards

Stefan

Offline

 

#38 2016-05-13 01:18:41 am

relishgargler
Member
From: Newport, MN
Registered: 2010-07-21
Posts: 84
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

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.

Offline

 

#39 2016-05-14 01:28:09 pm

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

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

Applescript:

   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:

Applescript:

   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

Last edited by StefanK (2016-05-15 01:57:48 am)


regards

Stefan

Offline

 

#40 2016-05-26 06:31:35 pm

relishgargler
Member
From: Newport, MN
Registered: 2010-07-21
Posts: 84
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

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.

Offline

 

#41 2016-05-27 12:21:59 am

relishgargler
Member
From: Newport, MN
Registered: 2010-07-21
Posts: 84
Website

Re: SKProgressBar 1.0, a fully scriptable progress bar

I'm having some trouble now. I changed just a few things from my original script in order to make it work with the new changes. First I moved the "set image path" and "set header" elements into tell blocks for the main bar. Then I added a quit delay to the main tell for SKProgressBar. All that worked fine, the first time. After that the window pops up, the files transfer, but there is no bar displayed. Any thoughts as to why?  All my previous "tell progress bar" blocks were correctly updated to "tell main bar" when I installed the new version.

I have also noticed that when I script in a quit command, it outputs this in the events:

Applescript:


tell application "SKProgressBar"
   quit
       --> error number 0
end tell

Offline

 

#42 2016-05-27 06:41:46 am

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

You should delete the old version, keeping both versions could cause interferences.

And add a launch command in the first application tell block

PS: I uploaded a new build (27) which fixes an auto layout issue.

Last edited by StefanK (2016-05-27 11:33:39 am)


regards

Stefan

Offline

 

#43 2016-06-28 07:52:54 pm

emendelson
Member
Registered: 2008-10-31
Posts: 346

Re: SKProgressBar 1.0, a fully scriptable progress bar

Stefan,

Do you have a sample script that shows the commands for version 1.5? When I download version 1.5 and the SKProgresssBar_scripting.scpt from the .dmg file in the first message, and try to run the script under OS X 10.11, I get this error:

SKProgressBar got an error: Can't set header to "header"

If I remove other lines, I get more errors.

Is there an updated script somewhere?

Thank you!

Offline

 

#44 2016-06-29 07:42:57 pm

JMichaelTX
Member
From: Houston, TX (The Woodlands)
Registered: 2014-07-12
Posts: 125

Re: SKProgressBar 1.0, a fully scriptable progress bar

emendelson wrote:

Stefan,

Do you have a sample script that shows the commands for version 1.5?

@Stefan:  Thanks for the update.

I too would be interested in an updated example script illustrating the new features.


MBP-15R, Early 2013 (& others)
Mac OS X Yosemite (10.10.5)

Offline

 

#45 2016-06-30 02:41:25 am

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

Does nobody read release notes ? ;-)

Since the new version can handle multiple bars, the properties header, header alignment, footer, footer alignment and image path have been moved to the progress bar class.

So replace progress bar with main bar and move the lines regarding the mentioned properties into the first tell main bar block.

New bars can be created and deleted with the standard make new and delete commands

This script is compatible with version 1.5

Applescript:

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"
   
   -- image path can be HFS or POSIX path, default is missing value (no image)
   
   tell main 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
       
       -- 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
       
       set image path to iconPath
       
   end tell
   
   set show window to true --> default is false
   tell main 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


regards

Stefan

Offline

 

#46 2016-06-30 06:05:58 am

emendelson
Member
Registered: 2008-10-31
Posts: 346

Re: SKProgressBar 1.0, a fully scriptable progress bar

Thank you, Stefan! Is there any chance you might update your first post with the current script and with a new .dmg that contains the script and the  application in one place?

Thanks again!

Offline

 

#47 2016-06-30 06:50:43 pm

JMichaelTX
Member
From: Houston, TX (The Woodlands)
Registered: 2014-07-12
Posts: 125

Re: SKProgressBar 1.0, a fully scriptable progress bar

StefanK wrote:

Does nobody read release notes ? ;-)

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:

1.  What does start/stop animation do?
  • I don't see any change in behavior when I don't use these commands.

2. What does "indeterminate" mean, and what is the effect of setting it to true/false?

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

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

5.  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:

https://dl.dropboxusercontent.com/u/7107976/Misc/SKProgressBar-1.5-Demo.gif

Applescript:


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

Last edited by JMichaelTX (2016-06-30 07:27:04 pm)


MBP-15R, Early 2013 (& others)
Mac OS X Yosemite (10.10.5)

Offline

 

#48 2016-07-01 05:45:07 am

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

Thank you for the animated GIF and the extended script.

JMichaelTX wrote:

1.  What does start/stop animation do?
  • I don't see any change in behavior when I don't use these commands.

2. What does "indeterminate" mean, and what is the effect of setting it to true/false?

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.

3. Could you possibly give us some some control over the text size for the labels on the window/bars:
  • window title
  • header
  • footer

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

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

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.

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

I haven't tested that, maybe it's possible. But it's not required to quit the app.


regards

Stefan

Offline

 

#49 2016-07-01 07:06:15 am

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

Re: SKProgressBar 1.0, a fully scriptable progress bar

[ANN] SKProgressBar 1.6

Changes :

- Add: Changeable sizes of header and footer. Sizes are mini, small (default) and regular and correspond to the recommended Cocoa system sizes.

    Example:
   

Applescript:

tell main bar to set header size to regular

- Add: The application is distributed in a code-signed .dmg including a demo script.

Download: SKProgressBar 1.6


regards

Stefan

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.092 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)