2 Replies Latest reply on Apr 9, 2008 9:23 AM by Marco van den Biggelaar

    How to assign script to menu item? (JS, CS3)

    Level 1
      Hi All,

      I can't find out how to assign a script to a menu item. Instead of clicking a script name in the script panel, I want to appear a menu item in the menu bar. When I click that name on the menu bar I want a certain script to run.
      I've managed to put the menu item in the menu bar, but not to assign the script to it.

      many thanks
      marco
        • 1. Re: How to assign script to menu item? (JS, CS3)
          Kasyan Servetsky Level 5
          Hi Marco,
          Here is an example:
          //--------------------------
          #targetengine "kasyan"
          var myScript1 = new File(app.filePath + "/Scripts/Scripts Panel/Preflight CS3 v3.2.jsx");
          var myScriptAction1 = app.scriptMenuActions.add("Preflight Document");
          var myEventListener1 = myScriptAction1.eventListeners.add("onInvoke", myScript1, false);

          var myScript2 = new File(app.filePath + "/Scripts/Scripts Panel/Rename Sections v3.1.jsx");
          var myScriptAction2 = app.scriptMenuActions.add("Rename Sections");
          var myEventListener2 = myScriptAction2.eventListeners.add("onInvoke", myScript2, false);

          var myScript3 = new File(app.filePath + "/Scripts/Scripts Panel/Check 100 3 SE.scpt");
          var myScriptAction3 = app.scriptMenuActions.add("Check Resolutuon of Images");
          var myEventListener3 = myScriptAction3.eventListeners.add("onInvoke", myScript3, false);

          var myScript4 = new File(app.filePath + "/Scripts/Scripts Panel/Resize Images v16.1.scpt");
          var myScriptAction4 = app.scriptMenuActions.add("Resize Images");
          var myEventListener4 = myScriptAction4.eventListeners.add("onInvoke", myScript4, false);

          try{
          var myScriptMenu = app.menus.item("$ID/Main").submenus.item("Scripts");
          myScriptMenu.title;
          }
          catch (myError){
          var myScriptMenu = app.menus.item("$ID/Main").submenus.add("Scripts");
          }

          var myScriptMenuItem1 = myScriptMenu.menuItems.add(myScriptAction1);
          var myScriptMenuItem3 = myScriptMenu.menuItems.add(myScriptAction3);
          var myMenuSeparator1 = myScriptMenu.menuSeparators.add();
          var myScriptMenuItem2 = myScriptMenu.menuItems.add(myScriptAction2);
          var myScriptMenuItem4 = myScriptMenu.menuItems.add(myScriptAction4);
          //--------------------------------------------
          Kasyan
          • 2. Re: How to assign script to menu item? (JS, CS3)
            Level 1
            Hi Kasyan,

            Thank you for your reply.
            You really helped me with this script.

            regards
            marco