Copy link to clipboard
Copied
Hi All,
I want to show a progress bar while executing script.
and i am using the following code for that:
var win = new Window("palette", "SnpCreateProgressBar", [150, 150, 600, 260]);
win.pnl = win.add("panel", [10, 10, 440, 100], "Script Progress");
win.pnl.progBar = win.pnl.add("progressbar", [20, 35, 410, 60], 0, 100);
win.pnl.progBarLabel = win.pnl.add("statictext", [20, 20, 320, 35], "0%");
win.show();
while(win.pnl.progBar.value < win.pnl.progBar.maxvalue)
{
// this is what causes the progress bar increase its progress
win.pnl.progBar.value++;
win.pnl.progBarLabel.text = win.pnl.progBar.value+"%";
$.sleep(10);
}
alert('Done!');
win.close();
But I am having following error when I run it:
Can you please tell me why it is happening....
Thanks
Harsh S
Copy link to clipboard
Copied
first, you're just showing 18 lines of code, your error is in Line 422
next, all the code in "Red" in your sample needs to be enclosed in quotation marks
Copy link to clipboard
Copied
@Harsh V Sharma,
please show your code for the progress bar completely. ( I can't find win.update() in your code). Also this call is only needed, if you work under MacOS. The palette works fine under Windows OS without win.update().
Copy link to clipboard
Copied
Hi follwing is the code i am using:
function artboardToJPGs(size)
{
var win = new Window("palette", "SnpCreateProgressBar", undefined, {borderless: true});
win.pnl = win.add("panel", [10, 10, 440, 100], "Creating JPEG");
win.pnl.progBar = win.pnl.add("progressbar", [20, 35, 410, 60], 0, 100);
win.pnl.progBarLabel = win.pnl.add("statictext", [20, 20, 320, 35], "0%");
win.show ();
for(i=0; i<10; i++)
{
win.pnl.progBar.value+=10; | |
win.pnl.progBarLabel.text = win.pnl.progBar.value+"%"; | |
win.update(); | |
}
var idx, j, sizes, jpegOpt, doc, docName, dF, artBds, abName, scale, jpgFile, destinationFolder, originalImage;
jpegOpt = new ExportOptionsJPEG();
jpegOpt.Optimization = true;
jpegOpt.QualitySetting = 100;
jpegOpt.blurAmount=0;
jpegOpt.artBoardClipping=false;
dF=new Folder(jpgImageFolder);
if ( !dF.exists ) dF.create();
doc = app.activeDocument;
docName=doc.name;
artBds = doc.artboards;
idx = artBds.getActiveArtboardIndex();
abName = artBds[ idx ].name;
var w= artBds[ idx ].artboardRect[2] - artBds[ idx ].artboardRect[0] ;
var h=artBds[ idx ].artboardRect[1] - artBds[ idx ].artboardRect[3];
var width= 100+ ( (size - w)/w ) * 100;
var height= 100+ ( ( size - h )/h ) * 100;
jpgFile = File( dF.fsName + '/' + fileName + size + 'x' + size + '.jpg' );
jpegOpt.horizontalScale =width;
jpegOpt.verticalScale = height;
doc.exportFile( jpgFile, ExportType.JPEG ,jpegOpt );
win.close();
}
Copy link to clipboard
Copied
Sorry, but your code is terrible posted in forum. …(like my English)
I think the counter i is not used in win.pnl
And because the steps are defined anyway : win.pnl.progBar.value + = 10;
try this:
while(win.pnl.progBar.value<100)
instead of:
for(i=0; i<10; i++)
Copy link to clipboard
Copied
your English is great.
Copy link to clipboard
Copied
Yaar I am posting my code again on this portal:
this is terrible because its not working:::
Copy link to clipboard
Copied
@Harsh V Sharma,
please read my last post again - carefully.
@CarlosCanto
Copy link to clipboard
Copied
I am having a similar problem too, but cannot find a way to replicate the problem outside my very convoluted current project..
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Harsh V Sharma,
you have now found a solution? Or you can answer my previous posting?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now