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

Need help with trying to execute palette jsxbin files.

Engaged ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

I've taken the code for executing palette jsxbin files and added code to select the jsxbin file but it doesn't work.

 

Any suggestions?

 

// execJSXBIN.jsx

/**
* @@@BUILDINFO@@@ execJSXBIN.jsx !Version! Sun Mar 08 2020 20:43:03 GMT-0500
*/

var fileObj;
var win = new Window("dialog");
win.text = "Execute JSXBIN 08 Mar 2020";
win.orientation = "column";
win.alignChildren = ["center", "top"];
win.spacing = 10;
win.margins = 16;

// GROUP1
// ======
var group1 = win.add("group", undefined, { name: "group1" });
group1.orientation = "row";
group1.alignChildren = ["left", "center"];
group1.spacing = 10;
group1.margins = 0;

var button1 = group1.add("button", undefined, undefined, { name: "button1" });
button1.text = "Execute JSXBIN";

var button2 = group1.add("button", undefined, undefined, { name: "button2" });
button2.text = "CLOSE";

button1.onClick = function ()
{
    win.close();
    executeJSXBIN();
};

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

win.show();

function executeJSXBIN()
{

    fileObj = File.openDialog("SELECT THE FILE TO BE PROCESSED .JSXBIN:");

    Decode(fileObj);

    ////////////////////////////////////////////////////////////////////////////////////////////
    function Decode(file)
    {
        try
        {
            if (!file.fsName.match(/\.(JSXBIN|jsxbin)$/i))
            {
                alert("ERROR!!!\nYOU HAVE SELECTED AN INVALID FILE\n\nYOU MUST SELECT ONLY FILES.JSXBIN?");
                return;
            }

            var bridgeTalk = new BridgeTalk();

            var photoShop = BridgeTalk.getSpecifier("photoshop");
            if (!photoShop) photoShop = "photoshop-60.064"; /* only for CS6x64, need redone*/

            bridgeTalk.target = photoShop;

            var jsxbin = "" + fileObj;

            var pth = new File($.fileName).parent.fullName + "/" + jsxbin;

            bridgeTalk.body = "$.evalFile(" + pth.toSource() + ")";
            bridgeTalk.send();

            //alert(" input: " + pth + "\n" + bridgeTalk.body);

            return true;
        }
        catch (e)
        {
            alert(e);
            return false;
        }
    }
}

 

Thanks,

RONC

TOPICS
Actions and scripting , SDK

Views

2.9K

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
Adobe
People's Champ ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

Something you have mixed everything in a bunch is not clear why.
The pth variable must contain the string - the full path to the jsxbin file.
Those in your case, you need to do something like this.
function executeJSXBIN()
{

    fileObj = File.openDialog("SELECT THE FILE TO BE PROCESSED .JSXBIN:");

    if (fileObj) Decode(fileObj);

    function Decode(file) // why named Decode ???
    {
        try
        {
            if (!file.fsName.match(/\.jsxbin$/i)) // jsxbin does not have to have a jsxbin extension
            {
                alert("ERROR!!!\nYOU HAVE SELECTED AN INVALID FILE\n\nYOU MUST SELECT ONLY FILES.JSXBIN?");
                return; // return what ? undefined ?
            }

            var bridgeTalk = new BridgeTalk();

            var photoShop = BridgeTalk.getSpecifier("photoshop");
            if (!photoShop) { alert("bad photoshop"); return; } // here should be code to determine the version of photoshop

            bridgeTalk.target = photoShop;

            bridgeTalk.body = "$.evalFile(" + file.fsName.toSource() + ")";
            bridgeTalk.send();

            return true;
        }
        catch (e)
        {
            alert(e);
            return false;
        }
    }
}
 

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
Engaged ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

r-bin,

 

Thanks for the fix.  The dialog code was borrowed from another script "CONVERT _PNG_DECODE_TXT.jsx" by Guippetto9XXXXX so the internal documentation needs for me get the terms correct.  Decode will be passToBridgeTalk. 

 

I have a couple of jsxbin or palettes that will not work in this or your original code.  How might I debug what is the problem?  I commented the bridgeTalk related lines in each and did save to binary but they don't run in this.

 

 

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
People's Champ ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

In order for everything to work in my code, the jsx and jsxbin files must have the same name without an extension and be located in the same folder, i.e. beside.
 
EDIT: in my OLD(!) code.
 

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
Engaged ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

r-bin,

They all are in the folder and names are the same for the jsx and jsxbin.  Most work but the CALC related ones don't.  I think there must be something going on in the save to binary in ESTK.

Thanks,

RONC

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
People's Champ ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

You can give me your complete code that does not work in the archive. Here or in PM. I'll see.
 

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
People's Champ ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

Does the code at the very beginning work for you if you translate it into JSXBIN?
 

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
Engaged ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

These routines worked as dialogs as jsx and jsxbin.  They work now as palettes as jsx only.  Trying the jsxbin the cursor jumps as it does for the working jsxbins but the palette doesn't show.

 

I'll PM the code to you.  It is about 500 lines but most is just choosing what to display.

Thanks,

RONC 

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
People's Champ ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Your jsx version contains an "error".
Line 8
paletteFunction();
need not.
It leads to a double function call.
It calls the function itself, and BridgeTalk does the same.

To form the JSXBIN file, leave all the code, including line 8 "paletteFunction();" and delete the code at the end after / ** /.

Form JSXBIN. Rename it to CALC4.dat.

Create the CALC4.jsx file and paste this code there.
var bridgeTalk = new BridgeTalk();

var photoShop = BridgeTalk.getSpecifier("photoshop");

// if BridgeTalk cannot determine the version, we define it ourselves. 
// It is assumed that the version is always x64 and StartupScripts is enabled. 
// On MAC may not work.

if (!photoShop) photoShop = "photoshop-" +photoshop.versionInfo.rootVersion + "64";

bridgeTalk.target = photoShop;

// We use the same script name but with the extension ".dat". 
// Using ".jsxbin" will cause duplicates to appear in the menu if the scripts are in the Photoshop scripts folder.

bridgeTalk.body = "$.evalFile(" + $.fileName.replace(/\.jsx$/i, ".dat").toSource() + ")"; 

// Send synchronously with a timeout of 5 seconds

bridgeTalk.send(5); 
 
Launch Photoshop. Everything works. If you don’t get it, I can send files.

I have problems with your script. So others may have a problem. When I close Photoshop, it crashes.
If delete (comment out) four lines with "ScriptUI.newFont", then everything works fine without crashes when close Photoshop.

How to solve the problem, I do not know yet. Crash occurs on both CC2020 (21.1) and CC2018.
 

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
Engaged ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

r-bin,

How about doing something like this:

At the very beginning of the code:

var jsx_dat = 1; // 0 == jsx   1 = jsxbin
if (jsx_dat === 1) paletteFunction();

function paletteFunction()

At the very end of the code:

var bridgeTalk, photoshop;
if (jsx_dat === 0)
{
    bridgeTalk = new BridgeTalk();

    photoShop = BridgeTalk.getSpecifier("photoshop");

    // if BridgeTalk cannot determine the version, we define it ourselves. 
    // It is assumed that the version is always x64 and StartupScripts is enabled. 
    // On MAC may not work.

    if (!photoShop) photoShop = "photoshop-" + photoshop.versionInfo.rootVersion + "64";

    bridgeTalk.target = photoShop;

    bridgeTalk.body = "var f=" + paletteFunction.toSource() + ";f();";
    bridgeTalk.send();
}
if (jsx_dat === 1)
{
    bridgeTalk = new BridgeTalk();

    photoShop = BridgeTalk.getSpecifier("photoshop");

    // if BridgeTalk cannot determine the version, we define it ourselves. 
    // It is assumed that the version is always x64 and StartupScripts is enabled. 
    // On MAC may not work.

    if (!photoShop) photoShop = "photoshop-" + photoshop.versionInfo.rootVersion + "64";

    bridgeTalk.target = photoShop;

    // We use the same script name but with the extension ".dat". 
    // Using ".jsxbin" will cause duplicates to appear in the menu if the scripts are in the Photoshop scripts folder.

    bridgeTalk.body = "$.evalFile(" + $.fileName.replace(/\.jsx$/i, ".dat").toSource() + ")";

    // Send synchronously with a timeout of 5 seconds

    bridgeTalk.send(5);
}

This way the code is always available.  My test look OK.

 

 

As far as the newFont lines, this is where I got the info:  http://www.indiscripts.com/post/2012/05/scriptui-fonts-facts .   I have no problem with PS latest.

 

RONC

 

RONC

 

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
People's Champ ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

I think it will work too.

But I have a problem.
Your script using fonts causes Photoshop to crash (upon exit). This only happens when using palettes.
I personally know that on the MAC there are even more problems with these palettes.
This may depend on the version of the operating system and the amount of memory. If you have the opportunity, check its (scripts) operation on another system, preferably like mine, on windows7.
 

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
LEGEND ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

If I'm right putting the maximum time to .send() (to return result) has sense if you use .onResult method.

 

bridgeTalk.onResult = function(v) {return res = v.body} bt.send(5)

 

Then within 5 seconds you'll get result returned from bridgeTalk.body.

 

If that will happen after 2 seconds, then Ps won't wait another 3 to get result, but will continue script.

 

btw it's better to set bridgeTalk to variable like, bt = bridgeTalk, as then you can have specific process.

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
LEGEND ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

There is bug in your code in this part:

 

!file.fsName.match(/\.(JSXBIN|jsxbin)$/i)

 

you can't use '!' for array (or == false), correctly at end of that line there should '.length':

 

!file.fsName.match(/.jsxbin$/i).length

 

but better if you use:

 

!/.jsxbin$/i.test(file.fsName)

 

 

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
People's Champ ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

You can do that.
if (!file.fsname.match (/\.Jsxbin$/i))
Match returns null or an array.

You cannot do
if (file.fsname.match (/\.Jsxbin$/i).length)
If null, then there will be an error.

Your code when null is equivalent to alert(!null.length).
This in my opinion is generally some kind of glitch.
 

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
People's Champ ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

I do not like this method (using BridgeTalk).

Firstly, it is not clear why the palette does not close.
Secondly, if there are a lot of elements, and especially fonts, then glitches appear (photoshop drops).

This code doesn’t work at all, but it should. What is the reason?
function fnctn()
    {
    try {
        var w = Window.find("palette", "1");

        if (w)
            {
            alert();    
            w.show();
            return;
            }

        var win = new Window("palette", "1", undefined, {resizeable: true} );
        win.spacing = 10;
        win.margins = 20;
        win.preferredSize = [500, 500];

        win.show();
        } 
    catch (e) { alert(e); }
    }


var bt = new BridgeTalk();

bt.target = BridgeTalk.getSpecifier("photoshop");;

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


CS6 does not fall for the calculator code that the author gave me and works much faster. Any CC drops wonderful.
 

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
LEGEND ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

It works when 'win' is without 'var'

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
People's Champ ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

there is complete confusion.

 

try {

alert(typeof(null));

} catch(e) { alert(e); }

try {

alert(null.a);

} catch(e) { alert(e); }


try {

alert(typeof(undefined));

} catch(e) { alert(e); }

alert(undefined == null);
alert(undefined === null);

 

EDIT: The moronic order of posts.

 

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
LEGEND ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Yes, you are right. It seems I had to think of something different I was doing lately, like:

 

if ((files = File('~/desktop').getFiles(/.jsxbin$/)).length)
	files[0].fsName.match(/\.(JSXBIN|jsxbin)$/i)

 

btw, something I just recalled:

'In JavaScript null is "nothing". It is supposed to be something that doesn't exist. Unfortunately, in JavaScript, the data type of null is an object. You can consider it a bug in JavaScript that typeof null is an object.' 

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
People's Champ ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Go nuts !!! 😲
Without var (for the palette), the calculator code does not cause Photoshop to crash.
I already like it. 😀
It is necessary that the author rechmbrs
note this feature to himself.
 
 

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
LEGEND ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Did you find it yourself or read my post? 🙂

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
People's Champ ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

you are a genius ))

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
People's Champ ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Apparently, if var is defined inside the function, then at the end of the function the window is credited to the garbage collection and then, or exactly when exiting, tries to destroy it and photoshop crashes.
 

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
LEGEND ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Actually yes. It refers to palette too. ESTK is built with using BridgeTalk's, and there are many palettes that works asynronously(?). Just take a look into this script to line 265: '35omvUI.jsx'

 

 

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
LEGEND ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

That not refers to 'palette', but if I may suggest you something, browse BridgeTalk in action:

 

'C:\Program Files (x86)\Adobe\Adobe ExtendScript Toolkit CC\Required'

 

In those scripts (including. those in 'cdic' and 'more' folders).

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
Engaged ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

r-bin,

 

So in the CALC code, I should remove var from dialog?  In the palette example I should remove the var from win.

 

RONC

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