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

Need to get the information of system as keyboard shortcut Set, workspace name

Explorer ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

Hi all,

After setting the keyboard shortcut and workspace by using:

var myShortcut = "Custom";
var myWorkSpace = "Shane";
app.applyShortcutSet(myShortcut);
app.applyWorkspace(myWorkSpace);

 

How can I detect that using the correct shortcut set and workspace for the active document? I have tried many days for this issue but I'm still stuck 😞
I can get the menu item of Keyboard Shortcuts by the below code but it's only read and can do nothing.
var menuItems = app.menus.everyItem().submenus.itemByName("Edit");
var result = app.menus.everyItem().submenus.itemByName("Edit").menuItems.everyItem().getElements();

for (var i = 0; i < result.length; i++) {
if(result[i].name == "Keyboard Shortcuts...") {
alert(result[i].title);
}
}
Thanks with much respect for your help!

TOPICS
How to , Scripting

Views

199

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 , Aug 09, 2022 Aug 09, 2022

Hi @ShaneLe147 ,

do you want to reset your applied workspace? So that it is in a defined order. The command to reset the active workspace is always available. We had a discussion about resetting the current workspace at startup some years ago at hilfdirselbst.ch. Gerald Singelmann contributed some working code for the German version of InDesign:

https://www.hilfdirselbst.ch/gforum/gforum.cgi?post=526503#526503

 

Note, that the substring "reset" or "Reset" is always localized. In German it's "zur

...

Votes

Translate

Translate
Community Expert ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

Hi @ShaneLe147 ,

do you want to reset your applied workspace? So that it is in a defined order. The command to reset the active workspace is always available. We had a discussion about resetting the current workspace at startup some years ago at hilfdirselbst.ch. Gerald Singelmann contributed some working code for the German version of InDesign:

https://www.hilfdirselbst.ch/gforum/gforum.cgi?post=526503#526503

 

Note, that the substring "reset" or "Reset" is always localized. In German it's "zurücksetzen" at the end of the name of the menu item. In an English environment it could be at the start of the string capitalized.

 

Some years ago I wrote a version of the script that does not depend on a localized string and will reset the current workspace. Just tested with my German InDesign 2022 on Windows 10. Hope, it will work with your English InDesign as well:

 

// ResetCurrentWorkspace-v2.jsx
// Uwe Laubender

/**
* @@@BUILDINFO@@@ ResetCurrentWorkspace-v2.jsx !Version! Wed Mar 08 2017 00:20:35 GMT+0100
*/

/*
	Locale independent!
	
	See also:
	
	Arbeitsplatzeinstellungen bei Start zurücksetzen [CS6/WIN 7 x64]
	Gerald Singelmann 24. Apr 2014, 12:49 Beitrag #4 von 5
	http://www.hilfdirselbst.ch/gforum/gforum.cgi?post=526503#526503
*/

var workspaceMenu = 
	app.menus.itemByName("Main").
	menuElements.itemByName("$ID/&Window").
	menuElements.itemByName("$ID/PW_Workspace");
	
var wsmItems = workspaceMenu.menuItems.everyItem().getElements();
var activeWorkspaceName = "";

for(var n=0;n<wsmItems.length;n++)
{
	if(wsmItems[n].checked)
	{
		activeWorkspaceName = wsmItems[n].name.replace(/^\[/,"").replace(/\]$/,"");
	};

	if(activeWorkspaceName != "" && wsmItems[n].name.match(activeWorkspaceName))
	{
		wsmItems[n].associatedMenuAction.invoke();
	}
};

 

Regards,
Uwe Laubender
( Adobe Community Professional )

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
Explorer ,
Aug 10, 2022 Aug 10, 2022

Copy link to clipboard

Copied

Hi @Laubender

Thanks a lot for your help !!!
I have edited your code a little bit and can get what I need ^^. This code is below.

 

var workspaceMenu =
app.menus.itemByName("Main").
menuElements.itemByName("$ID/&Window").
menuElements.itemByName("$ID/PW_Workspace");
// alert(workspaceMenu.name);

var wsmItems = workspaceMenu.menuItems.everyItem().name;
var activeWorkspaceName = workspaceMenu.menuItems.itemByName("BI");
activeWorkspaceName.associatedMenuAction.invoke();
if (activeWorkspaceName.checked) {
alert(activeWorkspaceName.name);
}

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
Explorer ,
Aug 10, 2022 Aug 10, 2022

Copy link to clipboard

Copied

Hi @Laubender,

I have one more thing, we cannot get the active keyboard shortcut, is it right? Thanks so much again!

ShaneLe147_0-1660193181010.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
Community Expert ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

@ShaneLe147 said: "we cannot get the active keyboard shortcut, is it right?"

 

Well, I agree.

At least I cannot see something related in the DOM.

The one thing that you can do is to load the Keyboard Shortcuts panel by using a menu command or a menu action with:

app.menuActions.itemByName("$ID/ShortcutsMenuItem").invoke();

But what then? Get the menu action for "Show Set…"? ( I doubt that this one is available. ) And how would one close the panel?

 

FWIW: And of course you can load a custom KBSC set if the *.indk file is stored in the subfolder InDesign Shortcut Sets of the InDesign preferences. But this is no indication what actually is loaded. You simply have to trust your:

app.applyShortcutSet(myShortcut);

 

Regards,
Uwe Laubender
( Adobe Community Professional )

 

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
Explorer ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

LATEST

I totally agree with you. I should create a boolean variable or something like that to ensure the keyboard shortcut is used correct after I apply it.

Anyway, thanks so much for your support. I very much appreciate it. Best regard!

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