• 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 I close my custom panel extension by script?

Enthusiast ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

Every menu item has a close command and a toogle command.

For example, I can first close the Actions menuItem to toggle it after.

This make sure the panel is visible (even if it is closed or not in first place)

app.runMenuItem (stringIDToTypeID('closeActionsPanel')); 

app.runMenuItem (stringIDToTypeID ("toggleActionsPalette"));

But, I have created my own custom Extension (for example, its name is "xxxx")

and I want the same behavior, I can't.

I can only toogle it ( on/off ) and it does not make sure the user remains with my extension visible.

This the only way of refreshing my panel extension (???).

Where is the stringIDToTypeID ("????????") to close my custom extension?

var myExtensionName = "XXXX";

var desc = new ActionDescriptor (); 

var ref = new ActionReference (); 

ref.putEnumerated (stringIDToTypeID ("menuItemClass"), stringIDToTypeID ("menuItemType"), stringIDToTypeID("extension")); 

desc.putReference (stringIDToTypeID ("target"), ref);

var ref1 = new ActionReference();

ref1.putName( charIDToTypeID('Mn  '), myExtensionName);

desc.putReference( charIDToTypeID('null'), ref1 );

try {

    var ddd = executeActionGet(desc).hasKey( ???????????????????   ); // close my custom panel extension

} catch(e) { $.writeln(e) }

// "select" toogles my custom extention: ON if OFF || OFF if ON

var descXX = executeAction (stringIDToTypeID ("select"), desc, DialogModes.NO);

TOPICS
Actions and scripting

Views

3.2K

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

Guide , Dec 09, 2016 Dec 09, 2016

You can get panel informaion with this..

$.writeln(listPanels().join("\n"));

function listPanels(){

var ref = new ActionReference();

Info = new Array();

ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("panelList") );

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

var desc = executeActionGet(ref).getList (stringIDToTypeID("panelList"));

for(var a = 0;a<desc.count;a++){

var Name = desc.getObjectValue(a).getString (stringIDToTypeID("name"));

var Vis =

...

Votes

Translate

Translate
Adobe
Enthusiast ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

This works for me

var idslct = charIDToTypeID( "slct" );

    var desc53 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref31 = new ActionReference();

        var idMn = charIDToTypeID( "Mn  " );

        ref31.putName( idMn, "CSS Hat" ); //maybe text from menu?

    desc53.putReference( idnull, ref31 );

executeAction( idslct, desc53, DialogModes.NO );

Try record this menu item:

2016-12-08_220453.jpg

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 ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

That's the problem. It toggles between ON/OFF.

It doesn't care if the extension is already opened or closed.

So, after running it, I can't be sure the extension to be opened for sure.

That is why I wanted to close it first and then use you solution.

To toggle I know it works with the select

charIDToTypeID( "slct" )

on the execute Action.

But I need it to close. And

charIDToTypeID( "Cls " )

doesn'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 ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

What about onload and unload events inside HTML panel: onunload Event

Could it work? I didn't tested it yet.

You could send this data to JSX and then save these custom values into Photoshop. I think, if you close panel, you kill CEP.exe process and if you open it again then page is reloaded.

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
Contributor ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

I use this to open and close panels

in a single script.

openPanel("xxx");// panel name

function openPanel(Name) {

    var desc1 = new ActionDescriptor();

        var ref1 = new ActionReference();

        ref1.putName( charIDToTypeID('Mn  '), Name);

    desc1.putReference( charIDToTypeID('null'), ref1 );

    try{

    executeAction( charIDToTypeID('slct'), desc1, DialogModes.NO );

    }catch(e){}

};

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 ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

But it doesn't allow you to make sure the panel will stay opened in the end.

It will toggle and if closed it opens, and if opened it closes.

I need it to refresh html passing new data from jsx.

To close+open again does that, but I need it to be opened in the begining. And this might not be the case sometimes.

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
Guide ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

You can get panel informaion with this..

$.writeln(listPanels().join("\n"));

function listPanels(){

var ref = new ActionReference();

Info = new Array();

ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("panelList") );

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

var desc = executeActionGet(ref).getList (stringIDToTypeID("panelList"));

for(var a = 0;a<desc.count;a++){

var Name = desc.getObjectValue(a).getString (stringIDToTypeID("name"));

var Vis = desc.getObjectValue(a).getBoolean(stringIDToTypeID("visible"));

var Ob = desc.getObjectValue(a).getBoolean(stringIDToTypeID("obscured"));

var ID = desc.getObjectValue(a).getString(stringIDToTypeID("ID"));

Info.push([[Name],[Vis],[Ob],[ID]]);

    }

return Info;

};

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 ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

Thank you!

Really a super Merlin solution!

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 ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

I have embedded your code to with my function:

updatePanel("myExtensionName");

//

function updatePanel (Name) {

    var Vis = false;

    var ref = new ActionReference();

    ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("panelList") );

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

    var desc = executeActionGet(ref).getList (stringIDToTypeID("panelList"));

    for(var a = 0;a<desc.count;a++){

        var listName = desc.getObjectValue(a).getString(stringIDToTypeID("name"));

        if (Name == listName) {

            Vis = desc.getObjectValue(a).getBoolean(stringIDToTypeID("visible"));

            var Ob = desc.getObjectValue(a).getBoolean(stringIDToTypeID("obscured"));

            var ID = desc.getObjectValue(a).getString(stringIDToTypeID("ID"));

            break;

        }

    }

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putName( stringIDToTypeID('menuItemClass'), Name);

    desc1.putReference( charIDToTypeID('null'), ref1 );

    if (Vis) {

        try {

            executeAction( charIDToTypeID('slct'), desc1, DialogModes.NO );

            executeAction( charIDToTypeID('slct'), desc1, DialogModes.NO );

        } catch(e) {}

    } else {

        try {

            executeAction( charIDToTypeID('slct'), desc1, DialogModes.NO );

        } catch(e) {}

    }

}

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 ,
Mar 12, 2018 Mar 12, 2018

Copy link to clipboard

Copied

Is it possible to update only the open panel without entering the panel name?

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 ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

LATEST

Been using Pedro's solution ever since (thanks!).

Yet, I can't get it to work for UXP plugin panels...

Opening these doesn't record into an action either, although it makes you believe it does.

Photoshop_VkikdeLDK4.jpg

So I got my first UXP panels and wanted both to open at the same time, using an action (playing a script).

I tried Pedro's function (full function in my file, of course):

updatePanel("TK8 Cx");
updatePanel("TK8 Multi-Mask");

First time I played this code from inside ExtendScript Toolkit I thought it had worked (unless I completely fooled myself somehow). So I arranged things to make it operational in an action, but anything I tried never worked again...

So...
(1) Shouldn't Adobe make these things record into an action? (as the UI already suggests they are doing so)

(2) Anyone found a way for UXP panels yet?

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