3 Replies Latest reply on Jun 2, 2013 4:32 AM by Trevorׅ

    Buttons Panel

    BridgetGreen

      Is there a way to get a list of all the buttons in a document, just as the hyperlinks panel has a list of all the hyperlinks panel? It seems like there's no way to search for buttons or go to a particular button except for eyeballing it.

        • 1. Re: Buttons Panel
          Salah Fadlabi Level 5

          Workaround: you can put all your Button on the Article panel and from there you can double click the button name to go to the button location on the page.

          • 2. Re: Buttons Panel
            BridgetGreen Level 1

            Thanks! Still don't understand why there isn't a list in the buttons panel, but I am grateful to have this workaround.

            • 3. Re: Buttons Panel
              Trevorׅ Adobe Community Professional

              This is a script I wrote a few weeks ago.

              You don't need any work around with it.

              See http://forums.adobe.com/message/5240408#5240408 for more details on the topic

               

              // Made By Trevor http://forums.adobe.com/message/5240408#5240408
              // TrevorsScript@Gmail.Com
              // DISACLAIMER - this script is completely not optamised with regards to speed  or accuracy, style etc. etc etc.
              // has not been tested properly and is not reflective of any pro scripts that I would be happy to do for money!!! 
               
              #targetengine Trevor
              var suil = app.scriptPreferences.userInteractionLevel,
              ser = app.scriptPreferences.enableRedraw;
              app.scriptPreferences.userInteractionLevel=UserInteractionLevels.INTERACT_WITH_ALL;
              app.scriptPreferences.enableRedraw =1;
              app.doScript("main()", ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Extract Combine and Resize Pages");
              app.scriptPreferences.userInteractionLevel= suil;
              app.scriptPreferences.enableRedraw = ser;
              function main ()
                  {
                      var doc = app.activeDocument, _button = app.activeDocument.buttons.everyItem().getElements(),
                            _pageItems = doc.allPageItems,l = _pageItems.length, as,  _printable,  n = 0, m = 0, b, c = 0, d = 0,
                            myMSOs = [], uniqueMSOsObj = {}, allMSOs = [], MSOnames = [], allMSOIds = [],
                            myButtons = [], uniqueButtonsObj = {}, allButtons = [], buttonNames = [], allButtonsIds = [];
               
                       //  first get the simple buttons     
                      while (l--)     if (_pageItems[l] instanceof Button) uniqueButtonsObj[_pageItems[l].id] = myButtons[n++] = _pageItems[l] else  if (_pageItems[l] instanceof MultiStateObject) uniqueMSOsObj[_pageItems[l].id] = myMSOs [m++] = _pageItems[l];
                      // now get the tougher one
                      var ll = myMSOs.length;
                      if (myMSOs .length > 0) while (ll--) findThoseButtons (myMSOs [ll]);
                      // filter out the duplicates and make them acceasable for the UI and what ever
                      for (b in uniqueButtonsObj) {allButtons[c] = uniqueButtonsObj[b]; buttonNames [c] = uniqueButtonsObj[b].name; allButtonsIds[c++] = uniqueButtonsObj[b].id};
                      for (b in uniqueMSOsObj) {allMSOs[d] = uniqueMSOsObj[b]; MSOnames [d] = uniqueMSOsObj[b].name; allMSOIds[d++] = uniqueMSOsObj[b].id};
               
                      // **************************************************************
                      // the  re - cursed function - not optimized !!!!! also don't know if it will get the lot of them ????? doubt it.
               
                      function findThoseButtons(multiState)
                          {
                                  var masi = multiState.activeStateIndex,
                                         _states = multiState.states.length;
                                  while (_states--)
                                      {
                                          var myState = multiState.states[_states];
                                          myState.active = true;
                                          var ObjAPItems = myState.parent.allPageItems,      // nead to use parent here!!!
                                                 msl = ObjAPItems.length;
                                          while (msl--) 
                                              {
                                                  if (ObjAPItems[msl] instanceof Button) uniqueButtonsObj[ObjAPItems[msl] .id] =myButtons[n++] = ObjAPItems[msl] 
                                                  else  if (ObjAPItems[msl] instanceof MultiStateObject) 
                                                      {
                                                          myMSOs [m++] = ObjAPItems[msl] ;
                                                          uniqueMSOsObj[ObjAPItems[msl].id] = ObjAPItems[msl] ;
                                                          findThoseButtons(ObjAPItems[msl]) ;
                                                      }
                                                 }
                                         }
                              multiState.states[masi].active = true;
                          }
                      // ***************** END OF FUNCTION *************************************
               
                      // *********************************************************************
                      //          SUI by me
                      //          This is quite nice if I say so myself :-) puts the window on the right 1/5 of the page
                      var sb = $.screens[0],
                      pannelBounds = [4*(sb.right-sb.left)/5, sb.top + 38, sb.right - 10, sb.bottom - sb.top],
                      pannelHeight = pannelBounds[3] - pannelBounds[1], 
                      pannelWidth = pannelBounds[2] - pannelBounds[0], 
                      heightGap = pannelHeight/100,
                      widthGap = pannelWidth/100,
                      w = new Window ("palette", "Button Info", pannelBounds),
                      myButtonList = w.add ("listbox", [widthGap ,heightGap, pannelWidth - widthGap, 24 * heightGap], buttonNames, {multiselect: false, }),
                      myMSList = w.add ("listbox", [widthGap ,heightGap * 25, pannelWidth - widthGap, 48 * heightGap], MSOnames, {multiselect: false, }),
                      makeReport = w.add ("editText", [widthGap ,heightGap * 49, pannelWidth - widthGap, 90 * heightGap],undefined, {multiline:true}),
                      makeMovie = w.add ("button",[widthGap ,heightGap * 91, pannelWidth - widthGap, 98 * heightGap], "Play Movie");        
                      // *************
                      myButtonList.onChange = function ()
                      {
                          allButtons[myButtonList.selection.index].select(); 
                          myMSList.selection = null;
                          var objReport = "", x;
                          for (x in allButtons[myButtonList.selection.index])
                              {
                                  objReport += (x + " : " );
                                 try { objReport += uniqueButtonsObj[allButtonsIds[myButtonList.selection.index]][x] + "\r" }
                                 catch (e) { objReport += "\rERROR\r" + e + "\r************\r";}
                                 // Sorry if you want the complicated results you can combine with the script in the post above do some DIY
                               };
                          makeReport.text = objReport;
                      }
                      // *************
                      myMSList.onChange = function ()
                      {
                          allMSOs[myMSList.selection.index].select(); 
                          myButtonList.selection = null;
                          var objReport = "", x;
                          for (x in allButtons[myMSList.selection.index])
                              {
                                  objReport += (x + " : " );
                                 try { objReport += uniqueMSOsObj[allMSOIds[myMSList.selection.index]][x] + "\r" }
                                 catch (e) { objReport += "\rERROR\r" + e + "\r************\r";}
                                 // See the above annotation
                               };
                          makeReport.text = objReport;
                      }
                      // *************
                      makeMovie.onClick = function () // make movie
                      {
                          for (var _frame = 0;  _frame<buttonNames.length; _frame++)
                              {
                                  allButtons[_frame].select();
                                  $.sleep(250);
                               }
                          for (var _frame = 0;  _frame<MSOnames.length; _frame++)
                              {
                                  allMSOs[_frame].select();
                                  $.sleep(250);
                               }
                      }
                      w.show ();           
                  }
              // ************ THE END ***************