9 Replies Latest reply on Jun 10, 2012 3:35 AM by Harbs.

    running InDesign in background

    jtcdesigns1

      So I wrote an automerge script for InDesign CS5.5 with ExtendScript and javascript. It works fine opening the document and merging records then save and close... Is there a way to have this run in the background instead as like a background task?

        • 1. Re: running InDesign in background
          absqua Level 4

          With InDesign desktop, not really. The closest you could come would be to add false as the second argument to any app.open() calls, which won't show the document layout window, and put

           

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

           

          at the top of your script. Be sure to set this back to UserInteractionLevels.INTERACT_WITH_ALL at the end of the script or in any catch or finally blocks.

           

          You would certainly run into problems if this was used on a machine where an actual user needed to use InDesign as well, and I would think you would absolutely need some good logging functionality built into your script as well. I'm no expert in this area, but I think you would also need to make sure your automated setup doesn't run afoul of the EULA. There have been posts on this forum that discuss this issue in some detail.

           

          Jeff

          1 person found this helpful
          • 2. Re: running InDesign in background
            jtcdesigns1 Level 1

            So would these lines go within the main function or outside of it.. example

             

            app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

            function main {

             

            }

            UserInteractionLevels.INTERACT_WITH_ALL

             

             

            or function main {

            UserInteractionLevels.INTERACT_WITH_ALL

             

             

            UserInteractionLevels.INTERACT_WITH_ALL

            }

             

             

            I've read from some that this is definitely capable in InDesign server.. but obviously no budget for that. I like that this is indeed in the script so it will only not interact when this particular script runs and its not permanent upon InDesign opening.

            • 3. Re: running InDesign in background
              absqua Level 4

              It doesn't really matter where you put them. I guess my preference would be to put them outside of the main function call and then have return statements in catch blocks within that function. That way you can be sure you get it set back. (The danger is that you don't get it set back and then can't figure out why any other scripts you use that have dialogs don't work.)

              1 person found this helpful
              • 4. Re: running InDesign in background
                Marijan Tompa [tomaxxi] Level 4

                I usually do it like this:

                 

                main ();
                
                function main () {
                    try {
                        if ( parseInt ( app.version ) > 6 ) {
                            var
                                _scriptRedraw = app.scriptPreferences.enableRedraw,
                                _userInteraction = app.scriptPreferences.userInteractionLevel;
                            app.scriptPreferences.enableRedraw = false;
                            app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
                            if ( app.documents.length ) {
                                var
                                    _dP = app.documents[0].preflightOptions.preflightOff;
                                app.documents[0].preflightOptions.preflightOff = true;
                                app.doScript ( doStuff, undefined, undefined, UndoModes.ENTIRE_SCRIPT, "My Function" );
                                app.activeDocument.preflightOptions.preflightOff = _dP;
                            } else {
                                /* NO DOCUMENTS OPENED */
                            }
                        } else {
                            /* WRONG APP VERSION */
                        }
                    } catch ( _ ) {
                        /* DISPLAY SCRIPT ERRORS */
                    } finally {
                        app.scriptPreferences.enableRedraw = _scriptRedraw;
                        app.scriptPreferences.userInteractionLevel = _userInteraction;
                    }
                }
                
                function doStuff () {
                    /*DO YOUR STUFF*/
                }
                

                 

                Hope that helps.

                 

                --

                Marijan (tomaxxi)

                http://tomaxxi.com

                1 person found this helpful
                • 5. Re: running InDesign in background
                  jtcdesigns1 Level 1

                  Thank you both. I'll give this a shot and hope for the best.

                  • 6. Re: running InDesign in background
                    rick_schwein

                    If you run any scripts that set the UserInteractionLevels to never, it probably would be good to start all others with

                     

                    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

                    • 7. Re: running InDesign in background
                      jtcdesigns1 Level 1

                      true, luckily this computer is strictly for automation so I have apps installed but they are only used for our automation program.

                      • 8. Re: running InDesign in background
                        -hans- Level 4

                        Hi,

                         

                        running Mac OSX you can tell "System Events" to set visible of InDesign to false ... (guess it'll be also possible to do this by using a shell-command)

                         

                         

                        --example

                        tell application "System Events" to tell process "Adobe InDesign CS5.5" to set visible to false

                         

                        tell application "Adobe InDesign CS5.5"

                            repeat 50 times

                                make new document

                            end repeat

                        end tell

                        perhaps something simular exists in VB¿!

                         

                        Have a nice day

                         

                        Hans-Gerd Claßen

                        • 9. Re: running InDesign in background
                          Harbs. Level 6

                          FYI,

                          Depending on exactly what you are doing, using InDesign "headlessly"  might put you in danger of violating the EULA. Take a look at the InDesign Desktop and InDesign Server EULAs to see what's permitted in each...

                           

                          Harbs