Copy link to clipboard
Copied
Hoping this is a simple thing to do and if someone would be kind enough to provide some script code for it.
I have 2 user workspaces called Dan1 and Dan2. Instead of manually changing the workspace every time I want to use the other one i'd like to assign a shortcut to the script that cycles between the two. Many thanks.
Here's a little script to do this. There are two limitations:
1. As far as I can tell, we can't tell which workspace is active, so I just have to start at the beginning. This means the first time you run the script in each session you may have to toggle twice to get the workspace you want.
2. Can you add a keyboard shortcut to a script? You may need a third party app to help? Sorry I'm not sure about that.
- Mark
/**
* Toggle between workspaces.
* @author m1b
* @version 2023-02-15
* @discu
...
Copy link to clipboard
Copied
Hi @danielw42205661, you might not need a script. Try using Edit > Keyboard Shortcuts... and choose the Window Menu.
- Mark
Copy link to clipboard
Copied
Thanks. I know about that, but I would then need 2 shortcuts (1 for each workspace) instead of 1 that cycles between the 2. Which isn't really what I want.
Copy link to clipboard
Copied
Here's a little script to do this. There are two limitations:
1. As far as I can tell, we can't tell which workspace is active, so I just have to start at the beginning. This means the first time you run the script in each session you may have to toggle twice to get the workspace you want.
2. Can you add a keyboard shortcut to a script? You may need a third party app to help? Sorry I'm not sure about that.
- Mark
/**
* Toggle between workspaces.
* @author m1b
* @version 2023-02-15
* @discussion https://community.adobe.com/t5/indesign-discussions/script-to-cycle-between-2-user-workspaces/m-p/13580436
*/
// Put your workspace names here:
var workspaceNames = ['Dan1', 'Dan2'],
key = 'workspaceForDan',
currentValue = app.extractLabel(key),
index = indexOf(currentValue, workspaceNames),
newIndex = index == -1 ? 0 : (index + 1) % workspaceNames.length,
newValue = workspaceNames[newIndex];
app.insertLabel(key, newValue);
app.applyWorkspace(newValue);
function indexOf(obj, arr) {
for (var i = 0; i < arr.length; i++) if (arr[i] === obj) return i;
return -1;
};
Copy link to clipboard
Copied
Thanks so much @m1b
Just tested it and it works great. Yep you can assign shortcuts to scripts within indesign.
Copy link to clipboard
Copied
Nice!