Skip navigation
Currently Being Moderated

Launch one CS app from another

Jan 9, 2012 2:40 AM

Tags: #illustrator #photoshop #cs5.5 #indesign #actionscript #extension #cssdk

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_t he_Creative-18456.html

 

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?

 
Replies
  • Currently Being Moderated
    Jan 9, 2012 4:04 AM   in reply to RorohikoKris

     

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 9, 2012 4:23 AM   in reply to Harbs.

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 9, 2012 4:31 AM   in reply to Harbs.

    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/csaw lib/com/adobe/csawlib/misc/BridgeTalk.html

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 9, 2012 6:15 AM   in reply to RorohikoKris

    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_be tween_CS_App-19196.html

     

    Regards

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 9, 2012 6:29 AM   in reply to Bob Stucky

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points