6 Replies Latest reply on Aug 10, 2013 10:58 PM by Trevorׅ

    on idle script.

    rajnikids Level 1

      Hi Forum,

       

      Need a help from you forum,

       

       

      Do we have options to run the javascript automatically when Indesign sofware is kept open....

       

      like applescript function...

       

      on idle...

       

      some functions..

       

      end idle..

       

      Will be very helpfull  & greatefull to you for the help....

        • 1. Re: on idle script.
          Trevorׅ Adobe Community Professional

          Yep look in the indesign scripting manual, seach the pdf for idleTask has a sample script there.

          If you don't manage let us know

          • 2. Re: on idle script.
            rajnikids Level 1

            HI Trevor,

             

            Thanks for you update. I tested it for deleting the files atonce, if anything copied and pasted into the folder.

             

            But it does, only one time, when the script is manually clicked to function.

             

            My request is to check the folder for files, if found delete immediately...

             

             

            #targetengine "session"

            main();

            function main()

            {

            var myIdleTask = app.idleTasks.add({name:"my_idle_task", sleep:0}); //here i changed the sleep time to zero, to check the script works continously...

            var onIdleEventListener = myIdleTask.addEventListener(IdleEvent.ON_IDLE,

            onIdleEventHandler, false);

            alert("Created idle task " + myIdleTask.name + "; added event listener on " +

            onIdleEventListener.eventType);

            }

             

            var myFolder = Folder("/Desktop/Studio1/WATCHED_FOLDER/CS6/IN_CS6");  //here the script should check and delete the files if found......

            var myFiles = myFolder.getFiles("*.indd");

            for ( i = myFiles.length-1; i >= 0 ; i-- ){

            myFiles[i].remove();

            }

             

            Many thanks for your support.

            • 3. Re: on idle script.
              Vamitul Level 4

              you should add the script to indesign's startup scripts. Again, it's in the manual.

              • 4. Re: on idle script.
                davidDav Level 1

                Hi vamitul,

                 

                after adding the script in Adobe Indesign/script/startup panel....

                 

                It works only when Indesign is opened and not automatically, when indesign is IDLE.

                 

                It will be a good to have the script continusly running when indesign is idle also...

                 

                 

                 

                 

                Thanks,

                David

                • 5. Re: on idle script.
                  Laubender Adobe Community Professional & MVP

                  @David – maybe InDesign is *never* idle, if the preflight function is working constantly?
                  Just a guess…

                   

                  Uwe

                  • 6. Re: on idle script.
                    Trevorׅ Adobe Community Professional

                    Hi Rajnikids

                     

                    var myIdleTask = app.idleTasks.add({name:"my_idle_task", sleep:0}); //here i changed the sleep time to zero, to check the script works continously...

                     

                    1) You annotation need changing here to

                    //here i changed the sleep time to zero, to make sure the script does not work at all as setting the sleep time to 0 is a way of killing the idleTask...

                     

                    See the manual.

                     

                    2) Let's say you want the script  to check continually so you make the sleep time 1 (thousandth of a second) it's going to be a huge strain on Indesings resources beside being unworkable.

                     

                    In short start with changing the sleep time to something normal like 1000 (1 second) probably it's not soooo bad if the file is zapped within 1 second

                     

                    Best of luck

                     

                    Trevor