ESTK palette

ScriptUI – BridgeTalk persistent Window examples

Davide Barranca —  — 7 Comments

In a previous post I’ve shown how to use either app.refresh() or the waitForRedraw() function in a loop in order to keep alive and idle a palette Window in Photoshop (since, unlike other CS apps like InDesign or the ExtendScript ToolKit, aka ESTK itself, palettes’ lifespan ends when there’s no more code to execute).

I’ve recently found that BridgeTalk can provide a good alternative since, quoting Adobe’s Bob Stucky, it “uses a persistent engine to process BT messages“. I’ve had no luck following the forum’s snippet, so (thanks also to some code kindly made available by Kasyan Servetsky) I’ve ended up with working examples that I’m going to share here.

BridgeTalk basics

The Javascript Tools Guide (installed by default alongside the ESTK) is quite straightforward:

The Adobe scripting environment provides an interapplication messaging framework, a way for to send and receive information and scripts from one Adobe application to another.

The interesting part is that one app can message itself: that is, to be the sender and the receiver at the same time. The communication system includes a small set of cross-DOM function (general ones: open, print, close, etc. or application specific: photomerge, etc), but you can control an application in its native DOM language via messages deployed by means of BridgeTalk objects. A simple example is as follows:

Things can be more sophisticated, but this main concept holds always  true. I’ll provide you with few examples, following different strategies.

Example #1 – Strings

Using a window resource string to create the ‘palette‘ and the .toString() function on the object.

Everything’s been packed into the WinObject – which .toString() function exactly replicate in the message string (you must add there the call to create an anonymous instance, though).

Example #2 – Binary Strings

Let’s say we’ve this usual script:

In ESTK do File – Export as Binary in a temp file, which will look like:

Add a backslash at each line’s end:

and use it as a message String for the BridgeTalk body:

This way you’re able to pack different stuff – an entire script – into the string.

 Example #3 – External scripts

You can load as a string an external file (either binary or not). In the following code, both files are in the same folder:


  • For some reason that I miss, if you don’t have any button’s callback (or at least a window.onClose() function, even an empty one) in the Window, the palette won’t display.
  • Be aware that window resource strings can’t contain backslashes \ as you’d write normally (see the code below). This applies to images embedded as strings as well – they don’t return any error yet prevent the window from displaying.

  •  The way you write a function results in different .toString() outputs, for instance:

When using Function Declaration / Named function the name is correctly parsed, while in Function Expressions the function assigned to the variable is anonymous and can’t return its name (Coffeescript for instance uses Function Expressions by default):

As a consequence, you’ve to explicitly make a correct message:

Following the above pattern, things get slightly more verbose if you need prototypes.


The BridgeTalk generated ‘palette‘ Window is finally a true, non-modal, idle Window object in Photoshop, no matter whether PC or Mac (the workarounds I’ve shown in a previous post work only partially on PC).

My suggestion, if you need such a feature, is to implement in an early stage of the script coding the BridgeTalk communication structure – since in a quite complex project I’m spending my time on (which started way before I knew about this technique), I’m still unable to make it work. The debugging is… quite complicate!

Print Friendly

7 responses to ScriptUI – BridgeTalk persistent Window examples

  1. Hi.
    I just came across this post trying to make a unified toolbar that launches all my scripts.
    After trying the code (In Photoshop CC) it seems Photoshop keeps taking focus from other programs.
    I was wondering if you might have a solution for that.

  2. This has definitely been a gold-mine, thanks.

    Tammuz–I had the same issue but pretty sure it’s related to the ESTK debugger. Once I broke the link from the target it didn’t occur anymore.

  3. Hello I am making a Illustrator extension and using the ScriptUI for the preferences dialog but, I can’t seem to find the numeric up down control…. does it exist in the ScriptUI and if not is there a different way to add it to the dialog .

    • Hi Viktor,
      I don’t think the numeric stepper exists in ScriptUI – I’m afraid you might need to use an EditText and bind extra ‘+’ and ‘-‘ buttons to custom functions operating on it.

  4. Hi Davide, Are you seeing a bug in CC 2015 where running this code more than once will create two palettes? One which is responsive and placed in the default location, and one which is non-responsive and is located in the same place where the palette was the previous time you closed it. Very odd.

Leave a Reply

Text formatting is available via select .

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">