9 Replies Latest reply: Jul 1, 2013 4:52 AM by JeffW. RSS

    Inter-app communication

    Rums Community Member

      hi,

      I have an CS extension for indesign, illustrator and photoshop. The extension works fine if invoked in the respective application. But from InDesign, can I invoke a file open request for say PhotoShop? That is, I need the user to stay within one application and open/process files in other applications. My panel has Illustrator files and photoshop file's path available to it. I have to fire file open and other file handling events to other apps. possible?

      My client has a need to work with indesign , photoshop and illustrator files. Even though they have one extension installed for all the 3 apps, they have to go back and forth between the apps to work with all their files. A one stop place will be handy for us.

       

      thanks for any help on this front.

        • 1. Re: Inter-app communication
          Bob Stucky Adobe Employee

          This shows 1 method using sockets.

           

          http://cookbooks.adobe.com/post_Inter_Application_Communication_with_the_Creative-18456.ht ml

           

           

          You can also use CSXSEvents to achieve the same goal so long as you are communicating between extensions in host applications that support CSXS.

           

          I would require less code to use CSXSEvents if the host support isn't an issue for you.

           

          An example of sending CSXSEvents between extensions in host applications is here:

           

          http://cookbooks.adobe.com/post_Synchronizing_Extension_Data_Models_between_CS_App-19196.h tml

           

          This one isn't doing exactly the same sort of thing - it takes an object that's in an extension in one host app, serializes it, sends it to an extension in a different host app, and then reconstitutes the object at the destination.

           

          Regards

          • 2. Re: Inter-app communication
            Rums Community Member

            hi

             

            Thanks for the quick response. Your tutorial on synchronizing data models is extremely useful for some of the tasks that I need to do. However, when I am inside my InDesign panel, I have  file listings and if the file happens to be a psd, I just want to fire a file open event to Photoshop so that Photoshop launches and the file gets open there. Is there an easier way to do it? or should I be filling my xml data with the file path and send it to my csxsevent?

            I want to support only Illustrator, PhotoShop and InDesign at this point. So, I am thinking CSXSEvent is the preferred approach. Also: in your video tutorial, you mentioned turning off the listener in the Photoshop end after the listener fires. Is that required? I would like Photoshop, Illustrator and InDesign to be always listening for "file open" events. When an application gets a file open event, the app. needs to launch (if not open already) and open the file sent from the source application?

             

            thanks,

            • 3. Re: Inter-app communication
              Bob Stucky Adobe Employee

              Glad you'll find the model synchronization handy!

               

              With Extendscript, there's BridgeTalk. Unfortunately, BridgeTalk was never intended to work via the mechanisms that support ActionScript. It's pretty much broken for two-way messaging. You can send a BridgeTalk message, it will get to the target application and execute. However, your extension will get no return communication to know if the call worked or not. Meanwhile, you can use BridgeTalk to find out if an application is running, and launch it as well.

               

              In your case, you'll need to write an extension that will run on application startup, and set up listeners. You'll pass the file path in the xml payload of the CSXSEvent.

               

              I probably wasn't clear on "turning off the listener". In the case of synchronizing models, we're creating a new instance of the model in the destination application every time the models sync up. We then transfer the properties of that model instance to the existing model. When we're done, there's that newly created model instance that we don't need. It has (as a part of instantiation) a listener as well. Because of that listener, it will never get garbage collected and would be a memory leak.

               

              In your case, you'll just be sending CSXSEvents back and forth, that's not a problem.

               

              As for starting the target application, I would recommend taking a look at this cookbook by Zak Nelson.

               

              http://cookbooks.adobe.com/post_Communicating_between_JavaScript_and_the_Creative-17383.ht ml

               

               

              You'll want to create a function that tests to see if your target app is running, and if not - to launch it. Once it returns, you can use CSXSEvents to find out when the application is ready.

               

              Does that process make sense??

              • 4. Re: Inter-app communication
                Rums Community Member

                Thanks a lot. I now understand how various pieces fit. I can't wait to try it.

                 

                thanks,

                • 5. Re: Inter-app communication
                  Rums Community Member

                  hi,

                  I was able to communicate to jsx from CS SDK using HostObject given in the cook book you have mentioned.

                  var  jsxInterface:HostObject = HostObject.getRoot(HostObject.extensions[0]);

                   

                  But every command, I execute using it seems to be in context to the host object under which the extension runs.

                  Same with CSXSInterface.instance.evalScript.

                   

                  a) How do I find all the target hosts the extension is built with (for example: photoshop, Illustrator and InDesign). Is there a way to query the manifest to do so?

                  b) If I get a list of all those target apps, how do I auto-launch them in order to use CSXSEvents? Is it possible to auto-launch all target applications?

                  c) If I can launch them using jsx, I can send the file path as a parameter to that launch jsx call itself. Does that mean, I can get away from using CSXSEvent?

                  I want to open a photoshop file from my extension running inside Indesign.

                  d) If I have to go the CSXSEvent route (in global scope) and  if 2 apps. support the same file type, how do I block a particular file format from going to a target application.

                  Can you please provide examples if any? My goal is to target a particular CS app and send it a file path requesting a file open command.  I am coming from the switchboard, patchpanel world and inter-app communication seemed so much easier there.

                   

                  thanks for any help.

                  • 6. Re: Inter-app communication
                    Bob Stucky Adobe Employee

                    I was able to communicate to jsx from CS SDK using HostObject given in the cook book you have mentioned.

                     

                    var  jsxInterface:HostObject = HostObject.getRoot(HostObject.extensions[0]);

                     

                     

                    But every command, I execute using it seems to be in context to the host object under which the extension runs.

                    Same with CSXSInterface.instance.evalScript.

                     

                    a) How do I find all the target hosts the extension is built with (for example: photoshop, Illustrator and InDesign). Is there a way to query the manifest to do so?

                     

                    You could read the manifest; however since you're writing the extensions I'd just hard code them.

                     

                     

                     

                    b) If I get a list of all those target apps, how do I auto-launch them in order to use CSXSEvents? Is it possible to auto-launch all target applications?

                     

                    You can't do that directly from CSXS. You can use the host object to call BridgeTalk.launch( target );

                     

                     

                     

                    c) If I can launch them using jsx, I can send the file path as a parameter to that launch jsx call itself. Does that mean, I can get away from using CSXSEvent?

                     

                    I want to open a photoshop file from my extension running inside Indesign.

                     

                    You can if you don't care about getting a reply back from BridgeTalk (to know if it worked or not).

                     

                     

                    d) If I have to go the CSXSEvent route (in global scope) and  if 2 apps. support the same file type, how do I block a particular file format from going to a target application.

                     

                    You'd have to put the target app in the xml, and filter on the receiver side.

                     

                     

                     

                    Can you please provide examples if any? My goal is to target a particular CS app and send it a file path requesting a file open command.  I am coming from the switchboard, patchpanel world and inter-app communication seemed so much easier there.

                     

                    I don't have any examples of this specifically, but I would think the answers above should help clear things up for you. The bottom line on inter-app communications is that this first release of CSSDK is limited. The switchboard/patchpanel world was BridgeTalk on steroids. With the CSSDK we got the performance from AS that wasn't there before. As for Interapp communications, we are well aware of the limitations of the current release. You can bet we are working on it.

                     

                     

                     

                     

                     

                     

                    • 7. Re: Inter-app communication
                      Rums Community Member

                      Thanks a lot. I got it working by using Bridgetalk. I have file format filters in place to target different applications. Bridgetalk code snippet  is for anyone who is interested. The target application is launched automatically.

                       

                      var bt:BridgeTalk = new BridgeTalk();

                      bt.target = "photoshop";

                      var script= "var runScript = function(...function parameters here...) { .....script here.... }";

                      script = script + "runScript(....input params...);";

                      bt.body = script;

                      bt.send();

                       

                      thanks once again.

                      • 8. Re: Inter-app communication
                        JeffW. Community Member

                        hi,

                         

                        I'm trying to send a simple string using CSXSEvent, like below, but the xml payload returns null:

                         

                        var data:XML= new XML();

                        data = <project></project>;

                        data.@project = currentView;

                         

                        var ev:CSXSEvent = new CSXSEvent("leaveAppEvent", CSXSEventScope.GLOBAL, XML(data))

                        CSXSInterface.instance.dispatchEvent(ev);


                        Although I receive the data in the other app, data outputs null:

                         

                        CSXSInterface.instance.addEventListener("leaveAppEvent", refreshView);

                         

                        protected function refreshView(event:CSXSEvent):void

                        {

                               trace("ExchangeDataTest  refreshView scope: " + event.scope);//outputs GLOBAL

                               trace("ExchangeDataTest  refreshView data: " + event.data);//outputs null

                        }

                         

                        Or is the data property not meant to be used like this?

                         

                        Thanks,

                        Jeff.

                        • 9. Re: Inter-app communication
                          JeffW. Community Member

                          oh silly, xml should of course have a root element, this works:

                          var initXML:XML = <root><projects></projects></root>

                                                                  initXML.@test = "yay"