3 Replies Latest reply on May 28, 2011 1:15 PM by Kasyan Servetsky

    How to update the screen in realtime?

    wildcardxy

      Hey,

       

      i am realy new in Indesign scripting

       

      i want to do a simple client script… the script should receive data and write it to a textbox (or do sth else with it).

       

      Everything works fine the only problem is: I dont know how to make this in realtime… for example every 10 seconds data comes from the server and should be directly displayed in the Indesign file.

       

      I need sothing like update the screen or flush the display…

       

       

      Thank you!

       

      All the best

       

       

       

       

       

      Code:

      myFrame = app.activeDocument.textFrames.add ();
      myFrame.geometricBounds = [30,30,200,200];

       

      reply = "";

       

      conn = new Socket;

       

      while(conn.open("localhost:12345")) {
      reply = conn.readln()
      $.write(reply)
      myFrame.contents = reply;

       

      //update the frame…
      }

        • 1. Re: How to update the screen in realtime?
          [Jongware] Most Valuable Participant

          Try recompose.

           

          But why are you using InDesign to communicate? If the document would be changed every 10 seconds, when is your client supposed to print or export to pdf?

          • 2. Re: How to update the screen in realtime?
            wildcardxy Level 1

            Hey thank you, it works but it is too slow,

             

            i try something like a remote control for indesign i am sending values to indesign to - for example- move a frame... rotate etc..

             

             

            this works more or less:

            ///

            myFrame = app.activeDocument.textFrames.add ();
            myFrame.geometricBounds = [30,30,200,200];

             

            for(;;)
            for(var i=0; i<100; i++){
            $.sleep(220)
            myFrame.move ([i, 16])
            myFrame.contents = "    "+i
            myFrame.recompose()

             

            }

             


            //////

             

             

             

             

            but this is too slow, what can i do? i can see all incoming values printed to the console but there is no fluent movement. but i realy need this, any ideas?

             

            ////////

             

             

            myFrame = app.activeDocument.textFrames.add ();
            myFrame.geometricBounds = [30,30,200,200];

             

            reply = "";

            conn = new Socket;

             

            while(conn.open("localhost:12345")) {
            reply = conn.readln()
            $.write(reply+".")

             

            myFrame.move ([reply, 50])
            myFrame.contents = reply

             


            myFrame.recompose()

             


            }

             

             

            thank you !!

            • 3. Re: How to update the screen in realtime?
              Kasyan Servetsky Level 5

              I am not sure if I understood what you want to achieve, but probably you could use the following approach:

              Start Bridge and using its scheduleTask method trigger an InDesign script every 10 seconds — that is send it from Bridge to InDesign via BridgeTalk.

               

              Here is an example illustrating my idea:

              #target bridge
              var myScript = 'CreateBridgeTalkMessage()';
              app.scheduleTask(myScript, 10000, true);
              
              function CreateBridgeTalkMessage() {
                   var bt = new BridgeTalk();
                   bt.target = "indesign";
                   var myScript = InDesignScript.toString() + '\r';
                   myScript += 'InDesignScript();';
                   bt.body = myScript; 
                   bt.send();
              }
              
              function InDesignScript() {
                   alert(app.documents.length + " documents are currently open in InDesign. This script is triggered by Bridge every 10 seconds using scheduleTask method");
              }