1

In an Applescript applet, progress can be shown like so:

set progress description to "A simple progress indicator"
set progress additional description to "Preparing…"
set progress total steps to -1

delay 5

set progress total steps to 100
repeat with i from 1 to 100
    try
        set progress additional description to "I am on step " & i
        set progress completed steps to i
        delay 0.2
    on error thisErr
        display alert thisErr
        exit repeat
    end try
end repeat

How would you access progress description, progress additional description, and progress total steps in Javascript for Automation (JXA)?

Coder-256
  • 5,212
  • 2
  • 23
  • 51

2 Answers2

2

IMO, the so-called "Progress Bar" provided by Yosemite is a joke. It does not display what most people would expect: A small window showing the progress.

Shane Stanley wrote the free ASObjC Runner app to provide this, and much more.

Take a look here for a real progress bar: Demo of real Progress Bar using ASObjC Runner app

This is written in AppleScript, but shouldn't be that hard to convert to JXA.

EDIT: I have converted the AppleScript code to JXA. You can get it here:

Demo of a Real Progress Bar for JXA using ASObjC Runner app

enter image description here

JMichaelTX
  • 1,659
  • 14
  • 19
  • IMO, the so-called "Progress Bar" provided by Yosemite is a joke. It does not display what most people would expect: A small window showing the progress. --> @JMichaelTX That's exactly what it does. Just File>Save as an application. – Coder-256 Jan 12 '16 at 21:14
  • @Coder256: That's find, but **by far most of my scripts**, and others I work with, **don't save the script as an app.** I stand by my assessment. I suppose it was you who gave me a down vote because you didn't like my comment. – JMichaelTX Jan 13 '16 at 00:00
  • 1
    I am amazed at how quickly people in this community are to make negative judgements and vote down both questions and answers they don't like. I was trying to offer a helpful suggestion above, but someone doesn't seem to like it. **If you made the vote down, have the integrity to post a comment stating why.** – JMichaelTX Jan 13 '16 at 00:03
1

See Progress in this page --> https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/Articles/OSX10-10.html

An example of script using the Progress object:

Progress.description =  "A simple progress indicator"
Progress.additionalDescription = "Preparing…"
delay(5)
Progress.totalUnitCount = 100;

for (var i = 1; i < 101; i++) {
    Progress.additionalDescription = "I am on step " + i
    Progress.completedUnitCount = i
    delay(0.1)
}
jackjr300
  • 7,111
  • 2
  • 15
  • 25