Skip to main content
Inspiring
August 9, 2022
Answered

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

  • August 9, 2022
  • 1 reply
  • 457 views

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!

This topic has been closed for replies.
Correct answer Laubender

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 )

1 reply

LaubenderCommunity ExpertCorrect answer
Community Expert
August 9, 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ü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 )

Inspiring
August 11, 2022

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);
}

Inspiring
August 11, 2022

Hi @Laubender,

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