• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

BridgeTalk script woks in all apps except Photoshop

Explorer ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Hi all, I'm doing some experiments in implementing a generic async function call in Extendscript (read setInterval and setTimeout).

I have have a very rough example working in AI, PPro and AE but the script won't execute correctly in Photoshop.  No errors, just doesn't seem to send the BridgeTalk message to itself.  I know there are better ways to implement the function call etc, just want to get it working in Photoshop for now.

Any ideas?

var testLoop = function(str) {

    for(c = 0; c  < 20; c++)  {

        $.writeln(str + String(c));

        $.sleep(100);

     }

};

var setTimeout = function(fn, fnCall, timeOut) {

    targetApp = BridgeTalk.getSpecifier(BridgeTalk.appName);

    if( targetApp ) {    

        var bt = new BridgeTalk;

        bt.target  = targetApp;

        bt.body = fn.toString() + "; $.sleep(" + timeOut + "); " + fnCall + ";";          

        //bt.onResult = function(returnBtObj) {

            //$.writeln("returnMessage");

        //};   

        bt.send();  

    }

}

$.writeln("MainThreadExecute A");

setTimeout(testLoop, "testLoop('Loop New Thread ')", 3000);

$.writeln("MainThreadExecute B");

TNKS!

G

TOPICS
Scripting

Views

920

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Add a timeout to bt.send(); I.E. bt.send(8);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 24, 2017 Mar 24, 2017

Copy link to clipboard

Copied

LATEST

Try this:

var testLoop = function(str) {

    for(c = 0; c < 10; c++)  { 

        $.writeln(str + String(c)); 

        $.sleep(100); 

     } 

}; 

 

 

var setTimeout = function(fn, fnString, timeOut) { 

    var targetApp = BridgeTalk.getSpecifier(BridgeTalk.appName);

    if( targetApp ) {      

        var bt = new BridgeTalk; 

        bt.target  = targetApp;  

        bt.body = "var func = " + fn.toSource() + "; $.sleep(" + timeOut + "); func('" + fnString + "');";

        bt.onResult = function(btMessage) {eval(btMessage.body);};

        bt.send();    

    } 

 

 

$.writeln("MainThreadExecute A");

setTimeout(testLoop, "Loop New Thread ", 1000); 

$.writeln("MainThreadExecute B");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines