Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scripting a Progress Bar only works if total time is < 5 Seconds

  • Scripting a Progress Bar only works if total time is < 5 Seconds

    Posted by Arne Münch on September 29, 2023 at 8:29 pm

    I am trying to write a simple progress bar script, to use in my other scripts.

    // Function to update the progress bar

    function updateProgressBar(value, max) {

    var progressBarWindow = new Window("palette", "Progress", undefined);

    var progressBar = progressBarWindow.add("progressbar", undefined, 0, max);;;

    // Function to update the progress value

    progressBarWindow.updateProgress = function (value) {

    progressBar.value = value;



    return progressBarWindow;


    // Example usage:

    var progressBar = updateProgressBar(0, 100); // Create a progress bar with a maximum value of 100

    var startTime = new Date().getTime(); // Get the current time

    var duration = 5000; // 5 seconds in milliseconds

    while (new Date().getTime() - startTime < duration) {

    // Update the progress bar value based on the elapsed time

    var elapsed = new Date().getTime() - startTime;

    var progress = (elapsed / duration) * 100;



    // Close the progress bar window when done


    this works totally fine for
    var duration = 5000
    var duration = 6000
    it hangs and the progress bar doesn’t close, and is not closeable by hand afterwards.

    The same behavior happend when i tried to use in a script which looks in a bunch of layers. if the total time the script needs is under 5 seconds everything works fine, if it needs longer it hangs.

    any ideas on that really strange behavior?

    Arne Münch replied 4 months, 2 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • Hector Vera

    October 2, 2023 at 10:41 pm

    That is rather strange, I thought there was no limits of how long you can animate a progress bar timing, did you tried closing and restarting the application and then raising the number on the progress bar duration is done? Maybe some computer specs may he holding it or something. Good to test everything so you may get closer to finding out whats the culprit of this stalling after duration exceeds 5000 in the coding.

  • Arne Münch

    October 12, 2023 at 12:16 pm

    Hi Hector
    Thanks a lot for replying.
    Sorry for replying so late. I was on a journey for some days.
    I actually closed and restarted and tested on another computer.
    The script works fine until

    var duration = 5344


    var duration = 5345
    or higher, there is this hanging and the bar doesn´t disappear.

    Very strange.
    Do you know how other people implement progress bars in After Effcect scripts?
    Maybe there is a slightly other way which doesn´t cause this trouble?

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy