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.
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.
// 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 (
...
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.
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".
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")))
}
};
}
};
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
I can reproduce; the Workspace seems to be updated only after some other step.