2 Replies Latest reply on Dec 16, 2013 2:49 AM by Laubender

    How to add progress bar?

    Learner Learner Level 1

      Hi All,

       

      I need a help on adding progress bar to my script.

       

      Here is my script.

       

      var mydoc = app.activeDocument;

      mydoc.zeroPoint = [0,0];

      var win = new Window("dialog", undefined, [0,0,465,72], );

      var graphicsfilepath;

      with(win){

                win.panel = add( "panel", [5,5,460,67], undefined );

                with(win.panel){

                          win.panel.sText = add( "statictext", [5,5,70,25], 'Imagepath: ' );

                          win.panel.eText1 = add( "edittext", [70,3,370,23], graphicsfilepath );

                          win.panel.but = add( "button", [375,3,445,25], 'Choose' );

               win.panel.but .onClick = function (){

               var graphicsfilepath = Folder.selectDialog ("Please select the graphics folder");

                      win.panel.eText1.text = graphicsfilepath;

               }

                          win.panel.but = add( "button", [300,30,370,52], 'Ok' );

                          win.panel.but = add( "button", [375,30,445,52], 'Cancel' );

                          }

                }

      win.center();

      win.show();

       

       

      placeart();

      var myfolder, myfiles, mypage, myrect;

       

       

      delfirstpage()

       

       

      function placeart(){

              myfolder = new Folder(win.panel.eText1.text);

              myfiles = myfolder.getFiles(myFilter);

              for (var i =0;i<myfiles.length;i++){

                      if (myfiles[i]!=0){

                              mypage = mydoc.pages.add();

                          }

                      else{

                              mypage = mydoc.pages.item(0);

                          }

                    var act_width=mydoc.documentPreferences.pageWidth;

                    //alert(topmargin)

                    var topmargin = mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.top;

                    var leftmargin = mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.left;

                    //alert(leftmargin)

                    mydoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;

                    mydoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;

                    mydoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

                   

                    var bottommargin = mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.bottom;

                                     var act_height=mydoc.documentPreferences.pageHeight;

                      var heigthwithoutmargin = act_height - (topmargin + bottommargin);

                      myrect = mypage.rectangles.add();

                      var gb = myrect.geometricBounds;

                      myrect.geometricBounds = [gb[0] + topmargin, gb[1] +leftmargin, gb[2] +topmargin, gb[3]+leftmargin];

                      var myfile = File(myfiles[i]);

                      myrect.place(myfile);

                      myrect.fit(FitOptions.FRAME_TO_CONTENT)

                  }

          }

      function delfirstpage(){

              mydoc.pages.everyItem().appliedMaster = mydoc.masterSpreads.item("A-Master")

              var mypage = mydoc.pages.item(0);

              mypage.remove();

              mydoc.pages.item(0).appliedMaster = mydoc.masterSpreads.item("B-Master")

          }

      function myFilter(myFile)

      {

                if(myFile.name.indexOf(".tif")>-1)

                return true;

                if(myFile.name.indexOf(".tiff")>-1)

                return true;   

                else if(myFile.name.indexOf(".eps")>-1)

                return true;

                if(myFile.name.indexOf(".gif")>-1)

                return true;

                if(myFile.name.indexOf(".jpg")>-1)

                return true;

                if(myFile.name.indexOf(".jpeg")>-1)

                return true;

         

          if(myFile.name.indexOf(".TIF")>-1)

                return true;

          if(myFile.name.indexOf(".TIFF")>-1)

                return true;

                else if(myFile.name.indexOf(".EPS")>-1)

                return true;

                if(myFile.name.indexOf(".GIF")>-1)

                return true;

                if(myFile.name.indexOf(".JPG")>-1)

                return true;

                if(myFile.name.indexOf(".JPEG")>-1)

                return true;

                else

                return false;

      }