3

My script analyses a bunch of InDesign files. Any warnings about missing fonts etc are irrelevant, thus I turn off user interaction during the core work:

// preparation code
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
// core work code
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
// finish code

Nevertheless I want to show a progress bar. I've set this up with ScriptUI:

progressPanel = new ProgressPanel(files.length, 500);
progressPanel.show();

for (i = 0; i < files.length; i++) {
    processFile( files[i] );
    progressPanel.incr();
    progressPanel.setText( files[i].name );
    progressPanel.show();
}

// Progress Panel, inspired from:
// http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/indesign/sdk/cs6/scripting/InDesign_ScriptingGuide_JS.pdf
// We make it a class.
function ProgressPanel (myMaximumValue, myProgressBarWidth){
    this.myProgressPanel = new Window('window', 'analyse InDesign files…');
    this.value = 0;

    this.myProgressPanel.myProgressBar
        = this.myProgressPanel.add('progressbar', 
                                 [12, 12, myProgressBarWidth, 24], 
                                    0, myMaximumValue);
    this.myProgressPanel.myText
        = this.myProgressPanel.add("statictext", 
                                   [15, 6, myProgressBarWidth, 24]);    
    this.show = function() {
        this.myProgressPanel.show();
    }
    this.hide = function() {
        this.myProgressPanel.hide();
    }
    this.setValue = function(value) {
        this.value = value;
        this.myProgressPanel.myProgressBar.value = value;
    }
    this.incr = function() {
        var inc = arguments.length ? arguments[0] : 1;
        this.value += inc;
        this.myProgressPanel.myProgressBar.value = this.value;
    }
    this.setText = function(text) {
        this.myProgressPanel.myText.text = text;
    }
}

This works fine in InDesign CS 6. But not in CC 2015, unless I remove all NEVER_INTERACT statements.

How can I show my progress bar while suppressing other user interaction, in both InDesign CS 6 and later?

Hauke
  • 451
  • 3
  • 11
  • Uh-oh. Looks like Adobe broke something. (Again.) You could check under what version your script is running with `app.version`, and then suppress the alerts or not, based on that. I don't think it's possible to suppress just a selection. – Jongware Oct 29 '16 at 20:43
  • Why not move the SOLVED section to a new answer? – Olalekan Sogunle May 11 '18 at 12:31

1 Answers1

0

At least for InDesign CC 2017, calling win.update() does the trick! (See Progress Bar bug. Summary of the situation in Adobe forum for more information about palette windows in ID CC.)

this.show = function() {
    this.myProgressPanel.show();
    this.myProgressPanel.update();
}

this.incr = function() {
    var inc = arguments.length ? arguments[0] : 1;
    this.value += inc;
    this.myProgressPanel.myProgressBar.value = this.value;
    this.myProgressPanel.update();
}
Yuri Khristich
  • 13,448
  • 2
  • 8
  • 23
Hauke
  • 451
  • 3
  • 11