3 Replies Latest reply on Jun 10, 2017 5:49 AM by Oriup

    Action in startup script needs to wait for IDCS3 plugins to fully load

    jhuddle123
      Hi all, if anyone has any advice for this, I'd be much obliged:

      I'm working with K4 and Made to Print in IDCS3 on a mac.

      I've got a javascript that automatically logs into K4 with a specific username. It needs to run right after InDesign launches. If I put it into the startup scripts folder, I get an error when it executes because K4 and/or Made to Print have not finished loading up on startup.

      The script works fine if I run it manually after K4 and Made to Print are loaded.

      I tried adding a delay to the beginning of the script, but that seems to simply halt all processing in InDesign instead of allowing the plugins to load and finish their startup processes.

      I tried moving the login script out of startup scripts, and instead put a pointer script into the ID startup script folder, to get the delay to happen outside of InDesign. That didn't seem to make a difference InDesign still halted till the delay was over.

      If you couldn't tell I don't spend much time scripting, so looking for advice!

      Thanks!
        • 1. Re: Action in startup script needs to wait for IDCS3 plugins to fully load
          liedzeit Level 2
          Nice to see that someone else is using K4 scripting.
          The easiest solution is to start InDesign by Applescript.

          tell application "Adobe InDesign CS3"
          activate
          try
          k4 log in k4 user name "rf" k4 password "mysecretpassword"
          end try
          end tell

          If you want to log in automatically after InDesign is started (the usual way) you need to define an eventlistener. As far as I can tell there is no event afterStart. But you can define a beforeNew or a beforeOpen event. Like this:

          #targetengine "session"
          main();
          function main(){
          var myEventListener = app.addEventListener("beforeNew", K4Login, false);
          }
          function K4Login()
          {
          app.k4LogIn("rf","mysecretpassword");
          }

          This way ID would try to log in before creating a new document. (It works. I have tested it.)
          Of course you would need to create a dummy document... You could also try a menu action...

          Ralf Funke
          • 2. Re: Action in startup script needs to wait for IDCS3 plugins to fully load
            Hi

            I am able to check in and check out the existing files in K4 using java scripting. Wat i am trying to do is to check in new files into K4 as layouts. The command that i use is

            app.documents[0].K4InitDatabaseData( K4ObjectType.K4_LAYOUT_OBJECT, "137102182");

            where the number 137102182 is the id of the publication.

            This command is not working. Am i doing something wrong or do I need to add any more commands to check in my active document into K4 as layout.

            Thanks