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

How can Scriptui SnpCreateDialog.jsx be changed to make "palette" that doesn't disappear?

Engaged ,
Mar 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

How can Scriptui SnpCreateDialog.jsx be changed to make "palette" that doesn't disappear upon opening?  Is there a simple change or do I need to use Bridgetalk?

 

RONC

TOPICS
Actions and scripting , SDK

Views

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

Copy link to clipboard

Copied

All code must be inside the fnctn function.
Do not use "//" comments inside this function.
Consider closing the window.
Using Alt + F4 may crash Photoshop.
The method needs to be explored. If you do not assign onClick, the code does not work (the window closes).
 

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

That's the correct beginning of the code:

function fnctn()
{
	var win;
	var bt;
	var i;

	var b1, b2, b3;

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

Using the graphics object causes Photoshop 2020 to crash if the script is run multiple times.
This is either a bad way or again Adobe messed up something.
So far I see no use other than using the most primitive interface.
 

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

This seems to work and is very simple to build.  I removed the the "with" stuff so it is more typing but what it is doing is more apparent.

 

function fnctn()
{
    var win;
    var bt;
    var i;

    var b1, b2, b3;
    var g0, g1, g2, g3;

    win = new Window('palette');
    win.spacing = 0;
    win.margins = 20;

    var font = ScriptUI.newFont("Arial", ScriptUI.FontStyle.BOLD, 20);

    g0 = win.add("group");
    g0.orientation = "row";
    g0.alignment = "center";
    g0.spacing = 2;
    g0.margins = 0;


    g1 = g0.add("group");
    g1.spacing = 0;
    g1.margins = 0;
    g1.preferredSize = [150, 60];

    g1.graphics.backgroundColor = g1.graphics.newBrush(g1.graphics.BrushType.SOLID_COLOR, [1, 0, 0, 1]);
    b1 = g1.add("statictext", undefined, "Test1");
    b1.justify = "center";
    b1.alignment = ["fill", "fill"];
    b1.graphics.foregroundColor = b1.graphics.newPen(b1.graphics.PenType.SOLID_COLOR, [0, 1, 0, 1], 1);
    b1.graphics.font = font;
    b1.onClick = function () { alert(this.text); };

    g3 = g0.add("group");
    g3.spacing = 0;
    g3.margins = 0;
    g3.preferredSize = [150, 60];

    g3.graphics.backgroundColor = g3.graphics.newBrush(g3.graphics.BrushType.SOLID_COLOR, [1, 1, 0, 1]);
    b3 = g3.add("statictext", undefined, "Test3");
    b3.justify = "center";
    b3.alignment = ["fill", "fill"];
    b3.graphics.foregroundColor = b3.graphics.newPen(b3.graphics.PenType.SOLID_COLOR, [0, 1, 1, 1], 1);
    b3.graphics.font = font;
    b3.onClick = function () { alert(this.text); };


    g2 = win.add("group");
    g2.spacing = 0;
    g2.margins = 0;
    g2.preferredSize = [150, 60];

    g2.graphics.backgroundColor = g2.graphics.newBrush(g2.graphics.BrushType.SOLID_COLOR, [0, 0, 1, 1]);
    b2 = g2.add("statictext", undefined, "Test2 - Close");
    b2.justify = "center";
    b2.alignment = ["fill", "fill"];
    b2.graphics.foregroundColor = b2.graphics.newPen(b2.graphics.PenType.SOLID_COLOR, [1, 1, 0, 1], 1);
    b2.graphics.font = font;
    b2.onClick = function () { alert(this.text); win.close(); };

    win.show();
}

(bt = new BridgeTalk()).target = 'photoshop';
bt.body = cnt(fnctn.toSource()), bt.send();

function cnt(v)
{
    return 'fnctn = ' + v + '; fnctn()';
}

 

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

Copy link to clipboard

Copied

This what my CALC looks like as a PALETTE in PS2020.  I applied blur and crop while it was resident and I see no problems.  Had to remove all of the // comments.

 

CALC running in PS2020 as a palette.CALC running in PS2020 as a palette.

 

I'm off to figure which type of button is best for the user error wise (clicking wrong one with plain text button vs graphically built one with symbols and colored background). 

 

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

Try closing the window or running the script several times. When you exit Photoshop, it will fall.
Is this happening to you?
 

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

No crashes no fails!!   Opened PS2020, opened image, loaded CALC,  Played with CALC,  blurred image,  Played with CALC, cropped image, Played with CALC.   Closed CALC.   blurred image, loaded CALC.  blurred image,  played with CALC, cropped image, played with CALC.   Closed PS.

 

Whatelse should I try?

 

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

Do you use a font for graphics?

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

Not sure what you are asking?   If text is involved yes like in your buttons.

 

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

Copy link to clipboard

Copied

btw to use in BridgeTalk backshlashes ('\') you have firstly export lines of codes with them to binary. I mean not all, for example this simple regexp:

'123'.replace(/\d/, 0)

 

will be:

 

eval('@JSXBIN@ES@2.0@MyBbyBn0ABJAnAEXzHjSjFjQjMjBjDjFBfFeDhRhShTRCYCicjEAFdAff0DzACByB')

 

 

All other lines in the same script don't have to be converted, just only part of codes with backslashes. So maybe it's why iconbuttons (with .png source) crash Photoshop.

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

K,

Was the backslash post to me?  I have no idea how to do what you are saying.  

 

I do have a script that takes png files and makes text from it if you are interested.  It does the full conversion.  Send me a mail if you want it.

 

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

Copy link to clipboard

Copied

That was to r-bin who is exploring new world 🙂

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

How do I get jsxbin files of source that runs as palette to work?   Nothing happens when I try to execute them.  Other than that I sure thank you for the help.

 

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

Copy link to clipboard

Copied

For example it is going to alert number 1:

 

function fnctn(){eval('@JSXBIN@ES@2.0@MyBbyBn0ABJAnAEjzFjBjMjFjSjUBfRBFdBff0DzACByB')}
(bt = new BridgeTalk()).target = 'photoshop', bt.body = 'fnctn = ' + fnctn.toSource() + '; fnctn()', 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
Engaged ,
Mar 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

Will not run as jsxbin.

 

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

Copy link to clipboard

Copied

You may also take result of fnctn.toString() between quatition marks and put directly to bt.body as one long line. Then export the whole to jsxbin. For example:

(bt = new BridgeTalk()).target = 'photoshop';
bt.body = 'fnctn = ' + 'function fnctn(){alert(1)}' + '; fnctn()'; bt.send();

 

Then as I said convert it to binaries. 

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

Thanks for you help.  You and K have covered a lot ground for me.

 

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

To Kukurykus

Neither works "photoshop-140" for 2020 (only "photoshop")
nor "photoshop-60" for CS6.
Or is it not that?
 

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

I answered higher:

 

 

BridgeTalk.getSpecifier('photoshop')

 

 


When Photoshop is running you can run above command that will say, you are running one of both: photoshop-140.064 or photoshop-60.064.

 

You may do it also from ESTK. When Photoshop is not targeted then it will show latest installed version. When targeted (and ran) it will tell you number for targeted Photoshop.

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

super!

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 01, 2020 Mar 01, 2020

Copy link to clipboard

Copied

Found an interesting feature.

The window with close() command is not destroyed as a "dailog", but continues to exist and occupy memory.
Multiple calls to the script will produce many invisible windows, which can cause a crash on exit.

This code does not create duplicates but calls the old window.
 

 

 

function fnctn()
    {
    try {
        var w = Window.find("palette", "1");
            
        if (w)
            {
            beep();
            w.show();
            return;
            }

        var d = new Window("palette", "1");
        d.spacing = 10;
        d.margins = 20;

        d.b1 = d.add("button", undefined, "Test1");
        d.b2 = d.add("button", undefined, "Cancel");

        d.cb = d.add("checkbox", undefined, "Box");

        d.b1.onClick = function () { alert(1); }

        d.b2.onClick = function () { d.close(); }

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


var bt = new BridgeTalk();

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

if (!ph) ph = "photoshop-60.064" // need redone
bt.target = ph;

bt.body = "var f="+fnctn.toSource()+";f();"; 
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
LEGEND ,
Mar 02, 2020 Mar 02, 2020

Copy link to clipboard

Copied

LATEST

I used to have the same problem, but I didn't know closing doesn't clear Window objects from memory. After all BridgeTalk is another parallel process next to Photoshop. They are surely independent ones, like different applications, but working together using their features. It's why you can use Window and Ps at same time. However 'find' method solves everything 😄

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