Skip to main content
October 8, 2006
Question

How to pass the control from InDesign to Bridge? (JS)

My purpose is to execute InDesign script and pass the control to Bridge and execute it´s script and then get the control back to InDesign. The #target "bridge" directive is not enough. I am looking similar to "tell application "xxx" " in AS where you can easily jump between applications.

When I am running the following lines I am getting error as I think I am still talking to InDesign instead of Bridge. The error is pointing to line after the #target "bridge" directive.

My InDesign CS2 script "ExecuteBridge.jsx" contains just following line:

app.doScript( File("Macintosh HD:ChangeColorOfLabel.jsx"))

and the file "ChangeColorOfLabel.jsx" contains the following (this works well if driven in ExtendScript editor, but gives error when saved as file to be executed):
#target "bridge"
var sels = app.document.selections;
for (var i = 0; i < sels.length; i++)
{
var thumb = sels;
var md = thumb.metadata
md.namespace = "http://ns.adobe.com/xap/1.0/";
md.Label = "Green";
}

I would be very pleased if someone could give a small sample how to pass control from one application to another using JS.

regards

Erkki
This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

October 9, 2006
I found myself a good example for my question from the Bridge scripting reference!

Here it is also for other scripters:

var targetApp = BridgeTalk.getSpecifier( "bridge", "1");
if( targetApp ) {
// construct and send message
}
var bt = new BridgeTalk; // create a new BridgeTalk message object
bt.target = "bridge"; // send this message to the Bridge application
// the script to evaluate is contained in a string in the "body" property
bt.body = "app.browseTo(Folder('Macintosh HD:Images:')); app.document.target.children.length;"
bt.onResult = function(returnBtObj)
{ processResult(returnBtObj.body); }
bt.send();

-------

It works well.

regards

Erkki
Translate
Participating Frequently
October 9, 2006
Hi,

You could use a BridgeTalk message to pass a script from InDesign to Bridge. Something like:

var myScript = "var sels = app.document.selections;";
myScript += "for (var i = 0; i < sels.length; i++) { ";
myScript += "var thumb = sels;";
myScript += "var md = thumb.metadata;";
myScript += "md.namespace = 'http://ns.adobe.com/xap/1.0/';"
myScript += "md.Label = 'Green';}";

var bt = new BridgeTalk();
bt.target = "bridge";

bt.body = myScript;

bt.send();

Hope it helps,
Translate