2 Replies Latest reply on Sep 25, 2013 1:50 AM by Afreesh

    how to run a script A from a button "Button 1" ?


      Hi all, I've got this problem for having a window with several buttons named "Button 1" "Button 2"... and run the script "Script A" if we click on the button 1, the script "Script B" if we click on the button 2 etc...

      Here is my short script :


      #target indesign

      //make a table of contents which send directly to the right script

      var w=new Window("dialog");

      var buttongroup=w.add("group");

      var panel=buttongroup.add("panel");


      var button1=panel.add("button",undefined,"Script A");

      var button2=panel.add("button",undefined,"Script B");

      var button3=panel.add("button",undefined,"Script C");

      var cancel=buttongroup.add("button",undefined,"Cancel",{name:'cancel'});






      function press(e){


              if(e.target.text=="Script A"){


                  app.doScript(new File("c/scriptA.jsx"),ScriptLanguage.javascript);


              else if(e.target.text=="Script B"){

                  app.doScript(new File("c/scriptB.jsx"),ScriptLanguage.javascript);


              else if(e.target.text=="Script C"){

                  app.doScript(new File("c/scriptC.jsx"),ScriptLanguage.javascript);





      Each script A, B and C begins with an app.dialogs.add()

      And here is the problem, it tells me that an alert or a modal dialog is already active

      I tried the w.close() but it doesn't work...

      I don't think addEventListener is what I need, maybe I'm wrong for using a window but it's the only way to give names to the buttons, isn't it ?