35 Replies Latest reply on Jun 23, 2016 10:09 AM by cbishop01

    ANN: automatic dialog after background export (exportPop.jsx)

    John Hawkinson Level 5

      A week or two ago, I wrote a script to pop up a dialog box after any background export, in response to the InDesign CS5 PDF export status thread. It doesn't seem like there's been feedback. I suspect it's sort of gotten lost in the noise in the general forum. So here we go again!

       

      Don't make me post it to InDesign Secrets!

       

      This script will automatically pop up a dialog box after every export finishes (PDF, IDML, whatever). It also makes sure that the Background Tasks window is turned on.

       

      You can download the script from here, or just paste in what follows and save as exportPop.jsx. See How to Install InDesign Scripts for installation instructions. If you save it in the Startup Scripts folder, it will run automatically when InDesign is started. Running it a second time disables it, if for some reason it causes problems.

       

      // exportPop.jsx -- pops up Background Tasks when you start an export
      //   and a modal dialog when an export finishes.
      // Beta version. Please post feedback at
      //   http://forums.adobe.com/thread/830572
      // John Hawkinson, 17 March 2011
      // Save in STARTUP SCRIPTS folder to start automatically.
      
      #targetengine session
      
      (function() {
          var
              old1 = app.eventListeners.itemByName("exportPop1"),
              old2 = app.eventListeners.itemByName("exportPop2");
              
          if (old1.isValid || old2.isValid) {
              if (old1.isValid) { old1.remove(); }
              if (old2.isValid) { old2.remove(); }
              alert("Export pop up window removed.\n"+
                  "Indesign will behave as normal.");
              return;
          }
          
          app.addEventListener("beforeExport", function() {
              var
                  tasksPanel = app.panels.itemByName("Background Tasks");
              if (tasksPanel) { tasksPanel.visible=true; }
          }).name = "exportPop1";
          
          app.addEventListener("afterExport", function(ev1) {
              var task, listener;            
              task = app.idleTasks.add({ name: "exportPop", sleep: 1000});
              listener = task.addEventListener(IdleEvent.ON_IDLE,
                  function(ev2) {
                      listener.remove();
                      task.remove();
                      alert(ev1.format+" export complete of "
                          +ev1.fullName+" at "+ev1.timeStamp);
                  });
          }).name = "exportPop2";
      
          alert("Export pop up window installed\n"+
              "Background Tasks will appear the start of an export\n"+
              "and a dialog will appear after each export complete.");
      }());