• 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 cycle between 2 user workspaces

Participant ,
Feb 14, 2023 Feb 14, 2023

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.

TOPICS
Scripting

Views

572

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

Community Expert , Feb 14, 2023 Feb 14, 2023

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-workspaces.gif

/**
 * Toggle between workspaces.
 * @author m1b
 * @version 2023-02-15
 * @discu
...

Votes

Translate

Translate
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

Hi @danielw42205661, you might not need a script. Try using Edit > Keyboard Shortcuts... and choose the Window Menu.

- Mark

Screenshot 2023-02-15 at 11.33.11.png

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
Participant ,
Feb 14, 2023 Feb 14, 2023

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.

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 ,
Feb 14, 2023 Feb 14, 2023

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-workspaces.gif

/**
 * 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;
};

 

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
Participant ,
Feb 14, 2023 Feb 14, 2023

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.

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 ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

LATEST

Nice!

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