0 Replies Latest reply on Sep 11, 2013 7:42 AM by techzol

    Adding Keyboard Shortcut when creating a new menu item via script


      I've come across a very nifty script for adding Close All to the File menu; and with a few simple modifications, create a Save All script, too.


      What I cannot seem to find is a way to add a keyboard shortcut so that I can invoke it with a couple of keystrokes (other than Ctrl-Alt-Shift W or S, which is already built in, but awkward to press 4 keys at once).


      Alternative, a menu short cut be nice, so, just as you can do Alt-F-S to save a file, it would be nice to be able to do something like Alt-F-B to do a save all.


      The ID6 scripting tutorial seems to indicate the the former is not possible (page 5). But I can't seem to find anything about the latter.


      Does anyone have any thoughts or suggestions. Below is the script.



      /*   FileCloseAll.js                              */

      /*                                                */

      /*   Add a "Close All" feature in the File menu   */

      /*                                                */



      #targetengine "FileCloseAll"



      // -----------------------------------------------

      var fcaTitle = "Close All";


      var fcaHandlers = {

          'beforeDisplay' : function(ev)


              ev.target.enabled = (app.documents.length>1);



          'onInvoke' : function()


              var doc;

              for( var i = app.documents.length-1 ; i>=0 ; i-- )


                  doc = app.documents[i];








      // -----------------------------------------------

      var fcaMenuInstaller = fcaMenuInstaller||



      // 1. Create the script menu action

      var mnuAction = app.scriptMenuActions.add(mnuTitle);


      // 2. Attach the event listener

      var ev;

      for( ev in mnuHandlers )





      // 3. Create the menu item

      var fileMenu = app.menus.item("$ID/Main").submenus.item("$ID/&File");

      var refItem = fileMenu.menuItems.item("$ID/&Close");




      return true;

      })(fcaTitle, fcaHandlers);