Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


CC2019 - Get name of current workspace function not working

Participant ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

I got this function form users r-bin and SuperMerlin in this group about a year ago. It gets the name of the current workspace and works fine in CC 2018 on Windows. However, Something changed in CC 2019 and it doesn't in CC 2019.

It gives "Error 8500: The requested property does not exist" for this line

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

The action descriptor gets created fine in the line above. I'm wondering if the action descriptor is just structured differently in CC 2019 than in 2018. So maybe the information is still in there but not in the same location in the descriptor. I have a general understanding of what this function does. It basically is reading the menu items and looking for the workspace name after the word Reset in the menu. However, I don't know how to see what is inside the action descriptor itself to be able to modify this to work in CC 2019 (if the info is in there somewhere). How do you go about fetching information from an action descriptor with unknown contents?

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;  

}

TOPICS
Actions and scripting

Views

886

Likes

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

Adobe Community Professional , Jan 12, 2019 Jan 12, 2019
Determine if Info panel is openHello! Change in 6th line: 7 to 10!

Likes

Translate

Translate
Adobe Community Professional ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

Determine if Info panel is open

Hello! Change in 6th line: 7 to 10!

Likes

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
Participant ,
Jan 13, 2019 Jan 13, 2019

Copy link to clipboard

Copied

Thanks. LOL, I had actually tried 5-9 for that but stopped there and was then trying to figure out how to read into the action descriptor. Did you just use trial and error to test until you found 10 worked? Or are you able to get that information from the action descriptor?

Likes

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 Community Professional ,
Jan 13, 2019 Jan 13, 2019

Copy link to clipboard

Copied

I tried manually higher numbers (instead of making a loop) to see that.

Leave only lines 2, 3, 4, 5 and then add this line to see name of menu:

desc.getObjectValue(7).getString(stringIDToTypeID('title'))

Likes

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 Community Professional ,
Feb 03, 2019 Feb 03, 2019

Copy link to clipboard

Copied

Hi Kukurykus ,

thank you for this!

Just a note for German PhotoShop CC 2019 users.

The string in line 10 will not work, because:

1. It's not "&Reset" in German, but: "&zurücksetzen".

2. The string is used at the end and not at the beginning of the workspace name and offset with a blank.

The following code is working with my German PhotoShop CC 2019 on Windows 10:

function getCurrentWorkspaceName()

{  

    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(10).getList(stringIDToTypeID("submenu")).getObjectValue(1).getList(stringIDToTypeID("submenu"));

  

    var workspaceName = "";

  

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

    {  

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

      

        // For German PhotoShop CC 2019:

        if( find.match(/ &zurücksetzen$/) )

        {

            workspaceName = find.replace(/\s.+$/,"");

            break;

        };

    };

    return workspaceName;

};

Now the question:
Can we write a script that is localization independent to get the active workspace name?

Regards,
Uwe

Likes

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 Community Professional ,
Feb 03, 2019 Feb 03, 2019

Copy link to clipboard

Copied

See what it alerts:

alert(localize('$$$/Menu/WorkSpace/Reset=&Reset ^0'))

If the name is in german, then replace ' ^0' part in result by regexp  to .*, and then again by regexp test names on the list.

Likes

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 Community Professional ,
Feb 03, 2019 Feb 03, 2019

Copy link to clipboard

Copied

Hi,

very good!

We can work with that, I think.

It returns the following string with my German PhotoShop CC 2019:

" ^0 &zurücksetzen"

What I do not understand is the ^0 part of the alert snippet code.

With or without using ^0 it is returning the same string.

Regards,

Uwe

Likes

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 Community Professional ,
Feb 03, 2019 Feb 03, 2019

Copy link to clipboard

Copied

LATEST

probably ' ^0' is somehow reserved for workspace name, but I don't know how to use it. Anyway like I said earlier you can then replace it with .* or if there is no need to use it then just add appropriate regexp that always translates other lanuage.

Likes

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