Below is a script I found in my notes. I'm not sure who wrote it, but it does show a progress bar with a close button that works with CS4 ( at least on my system ) // // createProgressWindow // title the window title // min the minimum value for the progress bar // max the maximum value for the progress bar // parent the parent ScriptUI window (opt) // useCancel flag for having a Cancel button (opt) // // onCancel This method will be called when the Cancel button is pressed. // This method should return 'true' to close the progress window // function createProgressWindow(title, min, max, parent, useCancel) { var win = new Window('palette', title); win.bar = win.add('progressbar', undefined, min, max); win.bar.preferredSize = [300, 20]; win.parent = undefined; if (parent) { if (parent instanceof Window) { win.parent = parent; } else if (useCancel == undefined) { useCancel = parent; } } if (useCancel) { win.cancel = win.add('button', undefined, 'Cancel'); win.cancel.onClick = function() { try { if (win.onCancel) { var rc = win.onCancel(); if (rc || rc == undefined) { win.close(); } } else { win.close(); } } catch (e) { alert(e); } } } win.updateProgress = function(val) { var win = this; win.bar.value = val; // recenter the progressWindow if desired // win.center(win.parent); win.show(); win.hide(); win.show(); } win.center(win.parent); return win; }; var arry = ['a','b','c','d']; var progressWindow = createProgressWindow("Progress...", 0, arry.length, true); progressWindow.isDone = false; progressWindow.onCancel = function() { this.isDone = true; return true; // return 'true' to close the window } try { for (var i = 0; i < arry.length; i++) { if (progressWindow.isDone) { break; } progressWindow.text = ("Processing element " + (i+1) + " of " + arry.length + "..."); progressWindow.updateProgress(i); $.sleep(5000) alert(arry); } } catch (e) { alert(e); } finally { progressWindow.close(); } $.sleep(5000); alert('done');
... View more