Skip to main content
Inspiring
January 23, 2010
Question

JS ScriptUI CS4: How to create an indeterminate progress bar?

  • January 23, 2010
  • 2 replies
  • 14947 views

Hi Folks,

Does anyone here know if ExtendScript (I'm using the CS4 flavor of ES) can produce an indeterminate (i.e., "barber pole") progress bar using ScriptUI's progressbar control? I've tried a number of value settings for the progress bar control in hopes that they would trigger the barber pole behavior, but so far, no luck.

My current workaround is to "loop" the progress indicator. In other words, when the progress bar's value > maxvalue, I reset the value back to minvalue. Then rinse and repeat. Not really what I want, but the task being processed takes quite a bit of time, so I need to show some sign of something happening to the user.

Thanks!

-- Jim

This topic has been closed for replies.

2 replies

Vamitul
Legend
September 6, 2012

sorry to bump an old thread, but i was hoping someone made some progress in this matter.

i'm in the same situation, i need a indeterminate progress bar for a script, i'we tried using a swf for it, but it only shows after the script has finished running. I can't update de palette/dialog/whatever very often, since my script basicly exports about 5 or 6 PDF's form very large documents, so the ony time i can update is when one PDF is exported, and that will not do.

Community Expert
September 6, 2012

@Vamitul – it's not about ScriptUI and might be no real help, but you could run the export in the foreground where the "normal" UI progress bar is showing up with the page names and some other statements…

For that use the old "exportFile()" method instead of the "asynchronousExportFile()" method.

Uwe

Inspiring
December 16, 2013

hi marc!

any news in the indeterminate progress bar department?

ps. it seems to work in hurrycovers


Hello,

I dont know if this issue is solved yet..... but,

I created a script that does batch processing (to many files)

I wanted exactly what was asked for here - a progress bar that shows the progress of the exporting.

@ Vamitul

     I was so happy when I saw that code... until I realized that it was getting into an endless loop!!

     (Only later did I see that you wrote that yourself at the end of the post )

@ Jim

     Your script does work somewhat well, but there are 2 problems:

    1. It doesnt show you the progress of the export
    2. I never got the "completed" message, so seemingly it was alwyas breaking because of the 60 second interval - which is not so good because every exporting takes different amounts of time.

I spent a nice amount of time on this tonight... until I gave up!

Then I tried a little more... and I got it!!!

I think others can bebefit fromt his as well, so here it is

// First we run a loop througout the export process.

// Through watching the finder window during the export,

// I was able to see that the size if the file does get updated

// (and task complete) during the scripts hang-up

// Therefore we can know when to break out of the loop by that condition

while (File(newPDFFile).length < 1) {

     progressBar.value = myTask.percentDone;

}

// However, it is still not considered a completed task!

// If we just let the script continue at this point, we will get an error message.

// So, here we just wait till the task is officially completed and then we are done!

// This gives us the exact timing - no extra waiting!

while (myTask.status != TaskState.completed) {

     myTask.waitForTask();

}

or, in Vamitul script,

     replace these lines:

while (myTask.percentDone<100) {
     pBar.hit(myTask.percentDone)
}

     with these lines:

while (File(expFile).length < 1) {
     pBar.hit(myTask.percentDone)
}

while (myTask.status != TaskState.completed) {

     myTask.waitForTask();

}

I tested this in my script and it works great

I hope it will be of help to others as well!

ATB

Davey

ramkumar_vp
Inspiring
January 23, 2010

Hi Jim,


Please see below the sample progressbar script.


     myPrs = new Window('palette', 'Batch Processing');
     myPrs.orientation = 'column';
     myPrs.alignment = 'right';
     myPrs.ProcessHead  = myPrs.add('statictext',[40,0,260,25], "Batch Processing...");
     myPrs.Process = myPrs.add("progressbar",[40,40,260,65]);
     myPrs.Label = myPrs.add('statictext', [150,75,200,120], "0%");
     myPrs.Process.value = 0;

     var LENGTH = 4;

     myPrs.show();

     for(i=0;i<10;i++){
         var PrCounter = 0;
         ProgressBar(++PrCounter, i+1 , 10);
         Function1();
         ProgressBar(++PrCounter, i+1 , 10);
         Function1();
         ProgressBar(++PrCounter, i+1 , 10);
         Function1();
         ProgressBar(++PrCounter, i+1 , 10);
         Function1();
     }

    

     function Function1(){
         for(var i=0; i<1000000;i++){}
     }

    

     function ProgressBar(v, x, y){
         var value = (Number(v) / LENGTH) * 100;
         myPrs.Label.text = Math.round(value) + " % ";
         myPrs.ProcessHead.text = "Batch Processing... [" + x + "/"+ y + "]";
         myPrs.Process.value = value;
     }


I think this script will solve your problem.


Regards,

Ramkumar .P

Inspiring
January 23, 2010

Hi Ramkumar,

Thanks for the reply, I really appreciate your help! Your idea is similar to what I am already using, which is fine as a workaround, but its not really what I'm after.

What I'm trying to find out is if it is possible, using ExtendScript and ScriptUI, to display a indeterminate progress bar. In other words, one where my code would never have to increment its value during its processing. Basically, I'm looking for the spinning barber pole type of progress bar that spins without having to interact with it within my processing code. See the image below:

Thanks again!

-- Jim

Harbs.
Legend
January 23, 2010

I don't think you can use the standard progress bar for what you want.

It should be possible to create a swf for that...

Harbs