I have been met with inconsistent results of success when trying to debug bridgetalk functions. while testing some things out I wrote a small script to create a QR code in Illustrator by Bridgetalking to Indesign to use the built in QR functions there, and then copy paste it into Illustrator. Overall here are my findings.
- you will need a timeout value in the send statement. this number is the number of seconds it will wait before resuming functions in the host application. as long as the script in the target can be handled in this time frame... everything works fine.
- you will need onResult and possibly OnReceived
- I found using the OnReceived to activate the application has been helpful. Some of the apps dont like to operate while not in the activate state
Someone smarter than me may be able to offer more insight, but i would try a recevied message that PS will do and also an onresult message that will be pushed back to illustrator, which can be a nothing statement and maybe push the timeout to be a little longer. Happy hunting, bridgetalk is a pain.
helpful resource
https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-message-object.html
var PromptRes = prompt("Website:","www.Google.com")
var BT = new BridgeTalk();
var appspecifier = "indesign";
if(!BridgeTalk.isRunning(appspecifier)){
BridgeTalk.launch(appspecifier);
}
//var ScriptFileMessage = 'var myDocument = app.documents.add();\rvar QRTangle = myDocument.rectangles.add({geometricBounds:[0.5,0.5,2,2]});\rQRTangle.createHyperlinkQRCode("' + PromptRes + '");\rQRTangle.select();\rapp.copy();\rmyDocument.close(SaveOptions.NO)'
var ScriptFileMessage = 'var myDocument = app.documents.add();'
ScriptFileMessage += 'var QRTangle = myDocument.rectangles.add({geometricBounds:[0.5,0.5,2,2]});'
ScriptFileMessage += 'QRTangle.createHyperlinkQRCode("' + PromptRes + '");'
ScriptFileMessage += 'QRTangle.select();'
ScriptFileMessage += 'app.copy();'
//ScriptFileMessage += '$.sleep(6000);'
/* testing that it will wait. as long as the function handles before the timeout on the send it should be fine */
ScriptFileMessage += 'app.activeDocument.close(SaveOptions.NO);'
BT.target = appspecifier;
BT.body = ScriptFileMessage;
/*alert(BT.body)*/
BT.onResult = function(){
app.paste();
}
BT.onReceived = function(){
/*forcing the trget application to become frontmost and active. this is the most troublesome part and sometimes likes to work, sometimes it doesnt*/
var IDActivate = File(BridgeTalk.getAppPath(appspecifier))
IDActivate.execute();
}
BT.send(10);