4 Replies Latest reply on Mar 4, 2011 8:43 AM by Kasyan Servetsky

    how do i target multiple applications?

    thomas rollins Level 1

      i'm setting up a document in indesign, and as i cycle through some images that are being included, for some of them i need to switch over to photoshop, perform some basic automated image editing, then save, and continue in indesign as normal. i have the scripts working separately for id and ps, and i have #target indesign / #target photoshop in the separate files, yet when i run the id script from the extendscript app, it always defaults to photoshop.

       

      so, how do i target both apps?

        • 1. Re: how do i target multiple applications?
          Kasyan Servetsky Level 5

          Use BridgeTalk (don't confuse it with with Bridge application). You can find examples on this forum, or on my site.

           

          Kas

          • 2. Re: how do i target multiple applications?
            thomas rollins Level 1

            thanks, somewhat confused though! i'm trying to use a wrapper function, processPhoto (that processes the image) like this:

             

            var bt = new BridgeTalk;
            bt.target = "photoshop";
            bt.body = "processPhoto(filename, newfilename, true);";
            bt.send();

             

            but no processing is taking place in ps. do i need to manually send each command via bridgetalk or can i use a container function?

             

            For reference processPhoto is itself a container of sorts:

             

            function processPhoto(fileName, newFileName, convertToGreyscale){
                var psFileRef = new File(fileName);
                psDoc = app.open(psFileRef);

             

                // convert to print resolution
                convertToPrintDPI(psDoc);

             

                if (convertToGreyscale){
                    convertToGreyscale(psDoc);
                }

             

                // save
                saveAndClose(psDoc, newFileName);
            }

            • 3. Re: how do i target multiple applications?
              Loic.Aigon Adobe Community Professional

              Unless I am wrong, there may be an error in teh way you are passing the fonction to Photoshop.

               

              function makeColors(cmykValues){
              var targetApp = BridgeTalk.getSpecifier( "indesign");
              if( targetApp ) {
                   var bt = new BridgeTalk;
                   bt.target = targetApp;
                   bt.body = getScriptMsg(cmykValues);
                  bt.onResult = function( inBT ) {myReturnValue(inBT.body); }
                   
                   bt.send();
                   }
              }
              
              function getScriptMsg(cmykValues){
                   var c = cmykValues[0];
                   var m = cmykValues[1];
                   var y = cmykValues[2];
                   var k = cmykValues[3];
                   var cmykValues = "["+cmykValues+"]"
                   var script = "\
                   var obj;\
                   (app.documents.length==0)? obj=app:obj=app.activeDocument;\
                   var c = obj.colors.add();\
                   with(c){\
                        model = ColorModel.PROCESS;\
                        space = ColorSpace.CMYK;\
                        colorValue="+cmykValues+";\
                        name=\"C"+c+"M"+m+"Y"+y+"K"+k+"\"\
                   }"
                   return script
              }
              

              Here is a sample of a bridgeTalk script I wrote. The Indesign function returns a string of the function body itself, not the function call

              Hope it helps

              Loic

               

              By the way, thanks a lot to Kasyan whom work and tutorials helped me a lot at the time

               

              Tribute to Kasyan :)

              • 4. Re: how do i target multiple applications?
                Kasyan Servetsky Level 5

                do i need to manually send each command via bridgetalk or can i use a container function?

                 

                Read this post.

                 

                Kas