6 Replies Latest reply: Jan 12, 2012 10:56 AM by RorohikoKris RSS

    Launch one CS app from another

    RorohikoKris Community Member

      Hi all,

       

      Newbie alert - sorry!

       

      I am currently stuck on something that seems simple, but I cannot get it to work - it's about coordinating between multiple CS apps.

       

      I want to cause one Creative Suite app (e.g. Photoshop) open a certain document (say a JPEG file) while running a CS Extension running in another Creative Suite app (e.g. Illustrator).

       

      I first naively assumed I could just use the app property of the Photoshop class (i.e. 'com.adobe.csawlib.photoshop.Photoshop.app') from an extension hosted by Illustrator, but I am not having much luck. One possible cause is that Photoshop is not necessarily running. When I try to refer to Photoshop.app while 'inside' an Illustrator extension, I do get an object back, but it's full of nulls and empty member variables - it's not properly instantiated, and as soon as I try to refer to something 'in' it (e.g. Photoshop.app.open(...)), a null exception is being thrown.

       

      I've tried pre-launching Photoshop manually, but that does not seem to help, and any which way, I want to automatically launch Photoshop if it has not been launched yet.

       

      The next thing I tried was to use an embedded ExtendScript - when one is using ExtendScript, it's fairly simple to talk to other apps in the Creative Suite. There are objects called 'photoshop', 'illustrator' and so on, and there is BridgeTalk.

       

      But when I call my ExtendScript from within ActionScript using the HostObject, it looks like I am missing all of the normal 'infrastructure' I've grown to expect when running ExtendScript. I suspect it's because I am in a separate engine that does not have the stuff I want to access.

       

      Then I tried to force things - I noticed the sample code that runs an ExtendScript in ActionScript has a phrase:

       

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

       

      and HostObject.extensions[0] is something like 'com.adobe.illustrator'. So I tried other strings here (e.g. running inside Illustrator, I tried 'com.adobe.photoshop') - no luck. Got a null in myBridgeScript.

       

      I looked at the CSXSEvents - but as far as I understand those would only help me when Photoshop is already running - Bob Stucky's cookbook article

       

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

       

      ends with: 'Possible extensions would be to launch Photoshop, if necessary, using Air's NativeProcess'. That sounds like bad news, and seems to indicate I'd have to go search for the Photoshop app path the hard way (keeping in mind that some people install their Creative Suite in odd places, so it's not always in '/Applications/Adobe Photoshop CSsomething' or 'C:\Program Files\Adobe\Adobe Photoshop CSsomething').

       

      Now, I can go do this the complicated way (calling down to the underlying operating system, try to find the correct Photoshop app (there might be more than one), and launch the document through the OS) - but I was really expecting there would be a simple magical trick to do it in a much more direct manner - it's clear the Creative Suite apps know about each other, so I was hoping to find a way to rely on their internal smarts to launch documents from one CS app into another CS app.

       

      Any ideas?

        • 1. Re: Launch one CS app from another
          Harbs. MVP

           

          Any ideas?

          Hi Kris!

           

          Yeah. Wait for Vulcan in CS Next... (sorry I couldn't resist...)

           

          I first naively assumed I could just use the app property of the Photoshop class (i.e. 'com.adobe.csawlib.photoshop.Photoshop.app') from an extension hosted by Illustrator, but I am not having much luck...

           

          I'd expect that. The CSAW libs are basically all smoke and mirrors. If you can't do it using ExtendScript, you can't do it in ActionScript. One app does not know another app's DOM...

           

          The way I'd handle it would probably be using Bridgetalk on the ExtendScript side of things with a (double) callback going back to the ActionScript side of things once the Bridgetalk returns its results to the ExtendScript layer.

           

          We should probably get together to solve this problem for the long-term...

           

          Harbs

          • 2. Re: Launch one CS app from another
            Harbs. MVP

            On second thought, you probably do not need the callbacks.

             

            You can do it using two (or rather three) separate ExtendScript-driven Bridgetalk (or non-BridgeTalk) scripts:

             

            Something like this should launch Photoshop and tell you its status:

             

            function launchPhotoshop(){
             var status = BridgeTalk.getStatus("photoshop");
             switch(status){
                       case "IDLE":
                       case "BUSY":
                       case "PUMPING":
                       return status;
             }
             BridgeTalk.launch("photoshop");
             return status;
            }
            

             

            You just need to keep polling until Photoshop is accessible. Once Photoshop is accessible, run another Bridgetalk script...

             

            HTH,

            Harbs

            • 3. Re: Launch one CS app from another
              Harbs. MVP

              It looks like there's a csawlib wrapper for BridgeTalk as well, so you can probably skip the ExtendScript if you are so inclined:

               

              http://127.0.0.1:60484/help/topic/com.adobe.cside.docs/references/csawlib/com/adobe/csawli b/misc/BridgeTalk.html

              • 4. Re: Launch one CS app from another
                Bob Stucky Adobe Employee

                Hi Guys,

                 

                BridgeTalk doesn't work in the AS enviroment. You can send a BT message, it will get to the target and will execute; however, callbacks simply don't happen. Also- if you are in AS, and call though to ES, callbacks still don't work. You can use BT to launch a target app, so long as you're in a CS host app environment. From Air you'd need to use NativeProcess.

                 

                Once started, again, so long as you are in a CS host app, CSXSEvents would be the way to go. (the article you reference, Kris, is for talking between say an Air app and Photoshop).

                 

                Here's a recipe for using CSXSEvents between host apps. It's not exactly what you want, but definitely shows you how to go about it.

                 

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

                 

                Regards

                • 5. Re: Launch one CS app from another
                  Harbs. MVP

                  Bob Stucky wrote:

                   

                  BridgeTalk doesn't work in the AS enviroment. You can send a BT message, it will get to the target and will execute; however, callbacks simply don't happen....

                  Yup. That's why I said to do it from ExtendScript.

                   

                  I find that I do an awful lot of ExtendScripting in my extensions...

                   

                  My sample should work as is because it doesn't rely on callbacks.

                   

                  If I'm not mistaken, using CSXSEvents would require a corresponding extension in the other app to handle the event. No? That's pretty ugly, and a lot of coding overhead...

                   

                  Personally, to run simple tasks in another app, I'd probably stick to BridgTalk via ExtendScript rather than play with CSXSEvents, but, to each their own...

                   

                  Harbs

                  • 6. Re: Launch one CS app from another
                    RorohikoKris Community Member

                    Hi Bob and Harbs,

                     

                    Great info, and it would be a solution for my use case - thanks so much! For now, I've put it into the 'to revisit later' basket - I have more important issues to fix first.

                     

                    Thanks so much!