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

Script to Get the Active Workspace Name

Community Expert ,
Jan 06, 2025 Jan 06, 2025

Copy link to clipboard

Copied

I found the following topic and code, where the active workspace can be loaded by name:

 

function sTT(v) {
    return stringIDToTypeID(v)
} 
(ref = new ActionReference()).putName (sTT('workspace'), 'Essentials'); 
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref);
executeAction(sTT('select'), dsc);
executeAction(sTT('reset'), dsc);

 

Is there a way to script the retrieval of the current workspace?

 

My final goal is to write the workspace's name to a text log file (among other things) and then load the named workspace at a later time. 

TOPICS
Actions and scripting

Views

100

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 2 Correct answers

Community Expert , Jan 08, 2025 Jan 08, 2025

Tried it, but target ordinal's workspace name could not be taken directly. Maybe I'm doing it wrong.

 

Technically, the current workspace can be obtained by getting application.menuBarInfo, and then referring to the name of the menu in Window > Workspace that has the checked value true.

 

That means in the ActionDescriptor.

Votes

Translate

Translate
Community Expert , Jan 09, 2025 Jan 09, 2025
// determine active workspace;
// 2025, use it at your own risk;
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("menuBarInfo"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var xxx = executeActionGet(r).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu"));
for (var m = 0; m < xxx.count; m++) {
var thisOne = xxx.getObjectValue(m);
// get window menu;
if (
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

Tried it, but target ordinal's workspace name could not be taken directly. Maybe I'm doing it wrong.

 

Technically, the current workspace can be obtained by getting application.menuBarInfo, and then referring to the name of the menu in Window > Workspace that has the checked value true.

 

That means in the ActionDescriptor.

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
Community Expert ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

@sttk3 – thank you for the reply, my AM knowledge is next to zero, this topic isn't critical to me, just something that would be "nice to do".

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
Community Expert ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

// determine active workspace;
// 2025, use it at your own risk;
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("menuBarInfo"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var xxx = executeActionGet(r).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu"));
for (var m = 0; m < xxx.count; m++) {
var thisOne = xxx.getObjectValue(m);
// get window menu;
if (thisOne.getString(stringIDToTypeID("title")) == "Window") {
var view_submenus = executeActionGet(r).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu")).getObjectValue(m).getList(stringIDToTypeID("submenu"));
}
};
// get workspace menu;
for (var m = 0; m < view_submenus.count; m++) {
var thisOne = view_submenus.getObjectValue(m);
if (thisOne.getString(stringIDToTypeID("title")) == "Workspace") {
var thisSubMenu = thisOne.getList(stringIDToTypeID("submenu"));
for (var n = 0; n < thisSubMenu.count; n++) {
    var checked = thisSubMenu.getObjectValue(n).getBoolean(stringIDToTypeID("checked"));
    if (checked == true) {
        alert (thisSubMenu.getObjectValue(n).getString(stringIDToTypeID("title")))
    }
};
}
};

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
Community Expert ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

@c.pfaffenbichler 

 

Thank you. The code works; however, it's a little inconsistent in my initial testing. This may be because my testing isn't realistic as I was just serially changing the workspace without doing anything else. More testing is required. Thanks again!

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
Community Expert ,
Jan 10, 2025 Jan 10, 2025

Copy link to clipboard

Copied

LATEST

I can reproduce; the Workspace seems to be updated only after some other step. 

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