• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

I want to know that how to use 'Bridge Talk'.

Community Beginner ,
Jun 14, 2015 Jun 14, 2015

Copy link to clipboard

Copied

var bt = new BridgeTalk;

     bt.target = "photoshop";

     var myScript = WIN.toString() ;

     bt.body = myScript;

     bt.send();

  

function WIN(){

var isDone, win, windowResource;

isDone = false;

windowResource = "palette{\

orientation: 'column', \

alignChildren: ['fill', 'top'],  \

preferredSize:[300, 130], \

text: 'ScriptUI Window - palette',  \

margins:15,  \

frameLocation:[1200,-10],\

   }"

win = new Window(windowResource);

win.show();

app.bringToFront()

}

JJMackā€Œ 

TOPICS
Actions and scripting

Views

2.3K

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

correct answers 1 Correct answer

Enthusiast , Jun 15, 2015 Jun 15, 2015

//New Bridgetalk

var bt = new BridgeTalk();

//Target application

bt.target = "bridge";

//Script to execute on target application

bt.body = /*script to execute*/;

//Results  if anything is to be returned

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

//If anything goes wrong, error message

bt.onError = function( inBT ) {alert(inBT.body); }

//Send the command with a timeout in seconds

bt.send(8);

Votes

Translate

Translate
Adobe
Enthusiast ,
Jun 15, 2015 Jun 15, 2015

Copy link to clipboard

Copied

//New Bridgetalk

var bt = new BridgeTalk();

//Target application

bt.target = "bridge";

//Script to execute on target application

bt.body = /*script to execute*/;

//Results  if anything is to be returned

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

//If anything goes wrong, error message

bt.onError = function( inBT ) {alert(inBT.body); }

//Send the command with a timeout in seconds

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
Community Beginner ,
Jun 15, 2015 Jun 15, 2015

Copy link to clipboard

Copied

thank u.  .i think it's more better if you give me a sample

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
Enthusiast ,
Jun 15, 2015 Jun 15, 2015

Copy link to clipboard

Copied

Here is an example of getting a list of selected files From Bridge any Folders are ignored.

alert(getSelectedFilesFromBridge().join('\n'));

function getSelectedFilesFromBridge(){

if (!BridgeTalk.isRunning("bridge")) {

BridgeTalk.launch("bridge");

var err = ["Bridge was not running, please run this script again\n Bridge will now be started."];

return err;

}

fileList = new Array();

var bt = new BridgeTalk();

bt.target = "bridge";

bt.body = "var f = " + Script.toSource() + "; f();";

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

bt.onError = function( inBT ) { alert(eval(inBT.body)); }

bt.send(8);

return fileList;

};

function Script(){

var sels = app.document.selections;

var Files=[];

if(!sels.length) Files.push("No Files Selected");

for(var z =0; z < sels.length;z++){

if(sels.spec instanceof File) {

Files.push(sels.spec);

    }

}

return Files.toSource();

};

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
Community Beginner ,
Jun 15, 2015 Jun 15, 2015

Copy link to clipboard

Copied

thank u very very much, my english is not good,I am studying now

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
Community Beginner ,
Jun 18, 2015 Jun 18, 2015

Copy link to clipboard

Copied

  1. function WinObject() {
  2.   // Long resource String for 'palette' Window
  3.   var windowResource ="dialog{text:'Script Interface',bounds:[100,100,400,170],button0:Button{bounds:[30,10,130,30] , text:'é€‰ę‹©å·²é€‰å›¾å±‚' },button1:Button{bounds:[160,10,260,30] , text:'ē§»åŠØ到当前' },panel0:Panel{bounds:[0,40,300,70] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true}}};"
  4. // ēŖ—å£ę–‡ä»¶åæ…é”»äøŗpalette ,äøčƒ½å‡ŗēŽ°åę–œēŗæ'\'
  5.   var win = new Window(windowResource);
  6.   win.botton0.onClick = function() { win.close() };
  7.   // åæ…é”»č¦ęœ‰å›žč°ƒēš„值
  8.   win.show();
  9. };
  10. var message = WinObject.toString();
  11. message += "\nnew WinObject();"
  12. var bt = new BridgeTalk();
  13. bt.target = "photoshop";
  14. bt.body = message;
  15. bt.send();

Why can't this jsx pop up a window?

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
Advocate ,
Jun 19, 2015 Jun 19, 2015

Copy link to clipboard

Copied

Typo on line 6 (should be win.button0).

Regards,

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

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
Enthusiast ,
Jun 19, 2015 Jun 19, 2015

Copy link to clipboard

Copied

There were a few errors in your code:

win.botton0.onClick should be win.button1.onClick

The var windowResource line needed a ; at the end.

Comments MUST be /* comment */

Comments using // will stop the script working.

function WinObject() {
  /* Long resource String for 'palette' Window */
  var windowResource ="dialog{text:'Script Interface',bounds:[100,100,400,170],button0:Button{bounds:[30,10,130,30] , text:'é€‰ę‹©å·²é€‰å›¾å±‚' },button1:Button{bounds:[160,10,260,30] , text:'ē§»åŠØ到当前' },panel0:Panel{bounds:[0,40,300,70] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true}}};";
/* ēŖ—å£ę–‡ä»¶åæ…é”»äøŗpalette ,äøčƒ½å‡ŗēŽ°åę–œēŗæ'\' */
  var win = new Window(windowResource);
  win.button1.onClick = function() { win.close() };
  /*  åæ…é”»č¦ęœ‰å›žč°ƒēš„值 */
  win.show();
};

var message = "var Win =" + WinObject.toSource() + "; Win();";
var bt = new BridgeTalk();
bt.target = "photoshop";
bt.body = message;
bt.send();

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
Community Beginner ,
Jun 19, 2015 Jun 19, 2015

Copy link to clipboard

Copied

function WinObject() {

  /* ę³Ø释ēš„ę–‡å­—äøčƒ½ē”±åŒę–œēŗæ开始 */

    /*åŖęœ‰åˆ›å»ŗPALETTEꉍåÆ仄ę”ÆęŒåŽå°*/

  var windowResource ="palette{text:'Script Interface',bounds:[100,100,400,170],button0:Button{bounds:[30,10,130,30] , text:'é€‰ę‹©å·²é€‰å›¾å±‚' },button1:Button{bounds:[160,10,260,30] , text:'ē§»åŠØ到当前' },panel0:Panel{bounds:[0,40,300,70] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true}}};";

/* ēŖ—å£å£°ę˜Žé‡Œäøčƒ½å‡ŗēŽ°åę–œēŗæ'\' */

  var win = new Window(windowResource);

  win.button0.onClick = function() { win.close()};

    var laysIDX = getSelectedLayersIdx();

    win.button1.onClick = function() {alert(laysIDX[0]);};

  /*  åæ…é”»č¦ęœ‰å›žč°ƒēš„值 */

win.show();

};

/*There were a few errors in your code:

win.botton0.onClick should be win.button1.onClick

The var windowResource line needed a ; at    the end.

Comments using // will stop the script working.*/

var message = WinObject.toString();

message += "\nnew WinObject();"

var bt = new BridgeTalk();

bt.target = "photoshop";

bt.body = message;

bt.send();

function getSelectedLayersIdx(){

      var selectedLayers = new Array;

      var ref = new ActionReference();

      ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

      var desc = executeActionGet(ref);

      if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){

        desc = desc.getList( stringIDToTypeID( 'targetLayers' ));

          var c = desc.count

          var selectedLayers = new Array();

          for(var i=0;i<c;i++){

            try{

              activeDocument.backgroundLayer;

              selectedLayers.push(  desc.getReference( i ).getIndex() );

            }catch(e){

              selectedLayers.push(  desc.getReference( i ).getIndex()+1 );

            }

          }

      }else{

        var ref = new ActionReference();

        ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));

        ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

        try{

            activeDocument.backgroundLayer;

            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);

        }catch(e){

            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));

        }

    var vis = app.activeDocument.activeLayer.visible;

        if(vis == true) app.activeDocument.activeLayer.visible = false;

        var desc9 = new ActionDescriptor();

    var list9 = new ActionList();

    var ref9 = new ActionReference();

    ref9.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

    list9.putReference( ref9 );

    desc9.putList( charIDToTypeID('null'), list9 );

    executeAction( charIDToTypeID('Shw '), desc9, DialogModes.NO );

    if(app.activeDocument.activeLayer.visible == false) selectedLayers.shift();

        app.activeDocument.activeLayer.visible = vis;

      }

      return selectedLayers;

};

Davide Barrancaā€Œ Philip Cordā€Œ  Thank U,  I got it ,The key lies in "Comments MUST be /* comment */".  But ,when I  Call a subroutine, it can't work

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
Enthusiast ,
Jun 20, 2015 Jun 20, 2015

Copy link to clipboard

Copied

LATEST

That is because you did not send the sub routine to Photoshop.

function WinObject() { 
  /* ę³Ø释ēš„ę–‡å­—äøčƒ½ē”±åŒę–œēŗæ开始 */ 
    /*åŖęœ‰åˆ›å»ŗPALETTEꉍåÆ仄ę”ÆęŒåŽå°*/ 
  var windowResource ="palette{text:'Script Interface',bounds:[100,100,400,170],button0:Button{bounds:[30,10,130,30] , text:'é€‰ę‹©å·²é€‰å›¾å±‚' },button1:Button{bounds:[160,10,260,30] , text:'ē§»åŠØ到当前' },panel0:Panel{bounds:[0,40,300,70] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true}}};"; 
/* ēŖ—å£å£°ę˜Žé‡Œäøčƒ½å‡ŗēŽ°åę–œēŗæ'\' */ 
  var win = new Window(windowResource); 
  win.button0.onClick = function() { win.close()}; 
    var laysIDX = getSelectedLayersIdx(); 
    win.button1.onClick = function() {alert(laysIDX[0]);}; 
  /*  åæ…é”»č¦ęœ‰å›žč°ƒēš„值 */ 
win.show(); 
    function getSelectedLayersIdx(){ 
      var selectedLayers = new Array; 
      var ref = new ActionReference(); 
      ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
      var desc = executeActionGet(ref); 
      if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){ 
        desc = desc.getList( stringIDToTypeID( 'targetLayers' )); 
          var c = desc.count 
          var selectedLayers = new Array(); 
          for(var i=0;i<c;i++){ 
            try{ 
              activeDocument.backgroundLayer; 
              selectedLayers.push(  desc.getReference( i ).getIndex() ); 
            }catch(e){ 
              selectedLayers.push(  desc.getReference( i ).getIndex()+1 ); 
           
         
      }else{ 
        var ref = new ActionReference(); 
        ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" )); 
        ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
        try{ 
            activeDocument.backgroundLayer; 
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1); 
        }catch(e){ 
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))); 
       
    var vis = app.activeDocument.activeLayer.visible; 
        if(vis == true) app.activeDocument.activeLayer.visible = false; 
        var desc9 = new ActionDescriptor(); 
    var list9 = new ActionList(); 
    var ref9 = new ActionReference(); 
    ref9.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); 
    list9.putReference( ref9 ); 
    desc9.putList( charIDToTypeID('null'), list9 ); 
    executeAction( charIDToTypeID('Shw '), desc9, DialogModes.NO ); 
    if(app.activeDocument.activeLayer.visible == false) selectedLayers.shift(); 
        app.activeDocument.activeLayer.visible = vis; 
     
      return selectedLayers; 
}; 
}; 
/*There were a few errors in your code:
win.botton0.onClick should be win.button1.onClick
The var windowResource line needed a ; atthe end.
Comments using // will stop the script working.*/ 
var message = WinObject.toString(); 
message += "\nnew WinObject();" 
var bt = new BridgeTalk(); 
bt.target = "photoshop"; 
bt.body = message; 
bt.send(); 

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