Skip to main content
Pedro Cortez Marques
Legend
December 8, 2016
Answered

How can I close my custom panel extension by script?

  • December 8, 2016
  • 2 replies
  • 3868 views

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);

This topic has been closed for replies.
Correct answer SuperMerlin

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;

};

2 replies

Zesty_wanderlust15A7
Known Participant
May 28, 2022

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.

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?

Jarda Bereza
Inspiring
December 8, 2016

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

Pedro Cortez Marques
Legend
December 8, 2016

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.

Jarda Bereza
Inspiring
December 9, 2016

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.