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

Determine if Info panel is open

Engaged ,
Jun 26, 2018 Jun 26, 2018

Copy link to clipboard

Copied

I am trying to get my script to determine if the info panel is open, but not necessarily visible. I got this piece of AM code from user Supermerlin a few years ago which works great to detect if a panel is visible. However, if the Info panel open in the workspace and docked in a panel group but not visible (another tab selected in the group), then it returns false. I kind of understand what this AM code is doing but I'm not an AM code expert by any stretch. I am wondering if there is another object value from the descriptor the determines if is is "open" but not visible that could be replaced in the code where 'visible' is. I'm not even sure how to get a list of the available object values for a descriptor.

Basically, I want the script to determine if the user has the info panel anywhere in there workspace before the script runs. Then if after the script runs it will close it if it wasn't in their original workspace. Taking a color sample from the script automatically opens the info panel which is why I'm trying to close it, but only if it wasn't opened to start with.

Anyone able to solve this puzzle?

function isInfoVis(){ 

var ref = new ActionReference(); 

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

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

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

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

    if(Name == 'Info'){ 

        return desc.getObjectValue(a).getBoolean(stringIDToTypeID('visible')); 

        break; 

        } 

    } 

}

TOPICS
Actions and scripting

Views

2.5K

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
Enthusiast ,
Jun 27, 2018 Jun 27, 2018

Copy link to clipboard

Copied

Is this what you want?

desc.getObjectValue(a).getBoolean(stringIDToTypeID('obscured'));

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 ,
Jun 27, 2018 Jun 27, 2018

Copy link to clipboard

Copied

Thanks for the reply. I tried 'obscured' after after I saw your response to my other post yesterday. Just based on the name, it seems that 'obscured' would mean it was open but not active/top in a panel. However, it returns false in all situations for me, at least on Windows CC 2018.  I'm not sure what 'obscured' is actually looking at. Maybe it is depreciated and is from an older Photoshop release?????

Anyway, this code always returns false for me. If you are able to get get it to return true then please let me know what toggles the output.

alert(isInfoObscured());

function isInfoObscured(){  

var ref = new ActionReference();  

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

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

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

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

    if(Name == 'Info'){  

        return desc.getObjectValue(a).getBoolean(stringIDToTypeID('obscured'));  

        break;  

        }  

    }  

}

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
Valorous Hero ,
Jun 27, 2018 Jun 27, 2018

Copy link to clipboard

Copied

You can try this to return the info panel to its original state.

 

var workspace = null;

 

var list = get_prop_value("application", null, "menuBarInfo", "submenu", 7, "submenu", 1, "submenu");

 

for (var i = 0; i < list.count; i++)

    {

    var s = list.getObjectValue(i).getString(stringIDToTypeID("title"));

 

    var n = s.indexOf("&Reset ");

    if (n == 0)

        {

        workspace = s.substr(7);

        break;

        }

    }

 

if (workspace)

    {

    var d = new ActionDescriptor();

    var r = new ActionReference();

    r.putName(stringIDToTypeID("workspace"), workspace);

    d.putReference(stringIDToTypeID("null"), r);

    executeAction(stringIDToTypeID("reset"), d, DialogModes.NO);

    }

see the function get_prop_value() here Re: Modifying Levels Adjustment Layer?

 

P.S.

You can also save the current workspace and in the * .psw file

see in what state

 

palette id = "17" is-closed = "false"

or

palette id = "17" is-closed = "true"

 

is.

 

After, restore the old workspace and delete the temporary.

 

P.S.S.

"obscure" means that the panel is partially covered by another panel.

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 ,
Jun 27, 2018 Jun 27, 2018

Copy link to clipboard

Copied

Thanks, I'll dig into it tomorrow.

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 ,
Jun 30, 2018 Jun 30, 2018

Copy link to clipboard

Copied

Not as straight forward as I thought it would be!

Results using current .psw file.

Columbs A & C = tab-group @active-palette ,@is-closed

Columbs B & D = Palette @id,@is-closed,@is-minimized,@current-state

A & B Info is not opened

C & D Info is opened and grouped with Actions,Properties & Adjustments

Info.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
Engaged ,
Jun 30, 2018 Jun 30, 2018

Copy link to clipboard

Copied

I tried to use the scripts you provided but I could not make it work correctly... I'm probably doing something wrong.

Is there a way to get the name of the current workspace? I searched for that but I could not find a way to do it. It would be really simple if I could just get the name of the workspace the user starts in. Then I could create a copy of that into a temp workspace for the script to run in. Then when the script is done it would switch back to the original workspace and delete the temp workspace. The issue is that without knowing the workspace the user started in, there is no way to know which one to switch back to.

Also, another complication is that my script is running from a custom HTML panel so I want to ensure that stays open too. If I could just get the name of the current workspace then it would be easy to just leave the workspace untouched and run in a temp workspace.

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 ,
Jun 30, 2018 Jun 30, 2018

Copy link to clipboard

Copied

Using r-bin​ code ...

alert(currentWorkspace());

function currentWorkspace(){

var ref = new ActionReference();

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

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

var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu"));

list =desc.getObjectValue(7).getList(stringIDToTypeID("submenu")).getObjectValue(1).getList(stringIDToTypeID("submenu"));

for (var i = 0; i < list.count; i++){

var find = list.getObjectValue(i).getString(stringIDToTypeID("title")).match(/\S+/g);

if(find[0].toString() == "&Reset"){ workspace = find[1].toString(); break;}}

return workspace;

};

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 ,
Jun 30, 2018 Jun 30, 2018

Copy link to clipboard

Copied

Thanks!  I spent the better part of a day trying to figure that out.

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 ,
Jun 30, 2018 Jun 30, 2018

Copy link to clipboard

Copied

The script worked great, except if the workspace had spaces in it, for example "Graphic and Web". In that case it would only return "Graphic".  I modified it so instead of indexing, this version just uses substrings which seems to work for names with spaces in it.

alert(currentWorkspace());

function currentWorkspace(){

var ref = new ActionReference();

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

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

var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu"));

list =desc.getObjectValue(7).getList(stringIDToTypeID("submenu")).getObjectValue(1).getList(stringIDToTypeID("submenu"));

for (var i = 0; i < list.count; i++){

var find = list.getObjectValue(i).getString(stringIDToTypeID("title"));

var find2=find.substring(0,6);

if(find2 == "&Reset"){

workspace = find.substring(7); break;}

}

return workspace;

};

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
Valorous Hero ,
Jun 30, 2018 Jun 30, 2018

Copy link to clipboard

Copied

In the function, you should use the var keyword

var list and var workspace to avoid possible breakage of variables with the same name outside the function.

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 ,
Jun 30, 2018 Jun 30, 2018

Copy link to clipboard

Copied

Agreed, thanks for catching the global variables. No need to make workspace and list global, especially with how common the words are.

Here is the final script which works perfectly. I added in a check at the beginning just in case the prior script run was aborted and it couldn't switch the workspace back.

There is maybe a way to replace the workspace functions with DOM code. However, I didn't see it in the Adobe docs so I just used script listener code.

//attempts to delete the temp workspace if it exists form last script run but is not active (if script was aborted)

try{deleteWorkspace ("my temp");}

catch(e){}

var originalWorkspace=currentWorkspace();

//alerts user if the workspace is set to the temp workspace, for the case the script got aborted on a previous run

if (originalWorkspace=="my temp"){alert("The workspace is using a temp workspace form the last time the script was ran. Switch the workspace before running this script again")}

else{

makeWorkspace("my temp");

try{

    //run main code here

    }

catch(e){

    //error catching code here

    }

finally{

switchWorkspace(originalWorkspace);

deleteWorkspace ("my temp");

}

}

function currentWorkspace(){

var ref = new ActionReference();

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

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

var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu"));

var list =desc.getObjectValue(7).getList(stringIDToTypeID("submenu")).getObjectValue(1).getList(stringIDToTypeID("submenu"));

for (var i = 0; i < list.count; i++){

var find = list.getObjectValue(i).getString(stringIDToTypeID("title"));

var find2=find.substring(0,6);

if(find2 == "&Reset"){

var workspace = find.substring(7); break;}

}

return workspace;

}

function makeWorkspace(name){

var idMk = charIDToTypeID( "Mk  " );

    var desc4 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref1 = new ActionReference();

        var idworkspace = stringIDToTypeID( "workspace" );

        ref1.putClass( idworkspace );

    desc4.putReference( idnull, ref1 );

    var idUsng = charIDToTypeID( "Usng" );

        var desc5 = new ActionDescriptor();

        var idNm = charIDToTypeID( "Nm  " );

        desc5.putString( idNm, name );

        var idPlt = charIDToTypeID( "Plt " );

        desc5.putBoolean( idPlt, true );

        var idkeyboardCustomization = stringIDToTypeID( "keyboardCustomization" );

        desc5.putBoolean( idkeyboardCustomization, false );

        var idmenuCustomization = stringIDToTypeID( "menuCustomization" );

        desc5.putBoolean( idmenuCustomization, false );

        var idtoolbarCustomization = stringIDToTypeID( "toolbarCustomization" );

        desc5.putBoolean( idtoolbarCustomization, false );

        var idreplace = stringIDToTypeID( "replace" );

        desc5.putBoolean( idreplace, false );

    var idworkspace = stringIDToTypeID( "workspace" );

    desc4.putObject( idUsng, idworkspace, desc5 );

executeAction( idMk, desc4, DialogModes.NO );

}

function switchWorkspace(name){

var idslct = charIDToTypeID( "slct" );

    var desc7 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref2 = new ActionReference();

        var idworkspace = stringIDToTypeID( "workspace" );

        ref2.putName( idworkspace, name );

    desc7.putReference( idnull, ref2 );

    var idIdnt = charIDToTypeID( "Idnt" );

    desc7.putInteger( idIdnt, 5634 );

    var iddontRecord = stringIDToTypeID( "dontRecord" );

    desc7.putBoolean( iddontRecord, false );

    var idforceNotify = stringIDToTypeID( "forceNotify" );

    desc7.putBoolean( idforceNotify, true );

executeAction( idslct, desc7, DialogModes.NO );

}

function deleteWorkspace(name){

var idDlt = charIDToTypeID( "Dlt " );

    var desc13 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref3 = new ActionReference();

        var idworkspace = stringIDToTypeID( "workspace" );

        ref3.putName( idworkspace, name );

    desc13.putReference( idnull, ref3 );

executeAction( idDlt, desc13, DialogModes.NO );

}

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 ,
Apr 10, 2021 Apr 10, 2021

Copy link to clipboard

Copied

LATEST

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