Running script from context menu (Right Click Menu)

Enthusiast ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

Hi Experts..

Please I want to know how to run a script from context menu? if it possible? can this be done? and how? and also indesign has many sub-context menus, can i access all levels? as an example (context menu of table) or (text frame)

Thanks in Advance

Best
M.Hasanain
TOPICS
Scripting

Views

124

Likes

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 3 Correct answers

Adobe Community Professional , Nov 19, 2021 Nov 19, 2021
Read into: How to Create your Own InDesign Menus Marc Autret, February 17, 2010 https://www.indiscripts.com/post/2010/02/how-to-create-your-own-indesign-menus Regards, Uwe Laubender ( ACP )

Likes

Translate

Translate
Adobe Community Professional , Nov 19, 2021 Nov 19, 2021
There are at least three kinds of context menus*: app.menus.item("$ID/RtMouseText"); app.menus.item("$ID/RtMouseLayout"); app.menus.item("$ID/RtMouseTable"); Some code you can play with below. The idea that's behind that code is by Dirk Becker, I think: Pick an existing menu item like "Copy" and clone it to the context menu. If it already exists, remove it first and then add the clone: /* Add-MenuItem-Copy-to-ContextMenu-RtMouseLayout */ ( function () { var miCopy = app.menus.itemByNam...

Likes

Translate

Translate
Adobe Community Professional , Nov 19, 2021 Nov 19, 2021
Also found this: /** * @@@BUILDINFO@@@ Add-MenuItem-Copy-Paste-to-ContextMenu-RtMouseTable.jsx !Version! Thu Jun 13 2019 18:42:56 GMT+0200 */ /* Tested and working with InDesign CC 2019 on Windows 10. See discussion at Adobe InDesign Forum: Edit right-click Menu in InDesign PJ in NH Jun 12, 2019 11:43 PM https://community.adobe.com/t5/indesign-discussions/edit-right-click-menu-in-indesign/m-p/10527790#M147117 Adapted code by Uwe Laubender. Original code by Dirk Becker for adding...

Likes

Translate

Translate
Adobe Community Professional ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

Read into:

 

How to Create your Own InDesign Menus
Marc Autret, February 17, 2010
https://www.indiscripts.com/post/2010/02/how-to-create-your-own-indesign-menus

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Enthusiast ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

Thanks a lot @Laubender , I will

Best
M.Hasanain

Likes

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
Adobe Community Professional ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

There are at least three kinds of context menus*:

 

app.menus.item("$ID/RtMouseText");
app.menus.item("$ID/RtMouseLayout");
app.menus.item("$ID/RtMouseTable");

 

 

Some code you can play with below.

The idea that's behind that code is by Dirk Becker, I think:

Pick an existing menu item like "Copy" and clone it to the context menu.

If it already exists, remove it first and then add the clone:

 

/*
Add-MenuItem-Copy-to-ContextMenu-RtMouseLayout
*/
( function () {

	var miCopy = app.menus.itemByName("$ID/Main").menuElements.itemByName("$ID/Edit").menuElements.itemByName("$ID/Copy").getElements()[0]; // menuItem

	var atc = app.menus.itemByName( "$ID/RtMouseLayout" ); // "$ID/RtMouseLayout" or "$ID/RtMouseText"

	try {

	  atc.menuItems.itemByName(miCopy.name).remove();

	} catch( ex ) {};

	atc.menuItems.add( miCopy.associatedMenuAction , LocationOptions.BEFORE , atc.menuItems[0] );

})();

 

 

As you can see from the code all you need is a menu action and a position for the new menu item done with method add() that is using three arguments: The menu action that it borrows from the "Copy" menu element, a relative position like BEFORE and the menu item that comes after.

 

Have fun with your experiments!

But do a save backup of your InDesign application folder before.

Or prepare to un-install and re-install InDesign if something goes wrong.

 

Regards,
Uwe Laubender

( ACP )

 

// EDIT: Corrected myself and added: "$ID/RtMouseTable"

Likes

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
Adobe Community Professional ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

LATEST

Also found this:

 

/**
* @@@BUILDINFO@@@ Add-MenuItem-Copy-Paste-to-ContextMenu-RtMouseTable.jsx !Version! Thu Jun 13 2019 18:42:56 GMT+0200
*/

/*
	Tested and working with InDesign CC 2019 on Windows 10.
	
	See discussion at Adobe InDesign Forum:
	
	Edit right-click Menu in InDesign
	PJ in NH Jun 12, 2019 11:43 PM
	https://community.adobe.com/t5/indesign-discussions/edit-right-click-menu-in-indesign/m-p/10527790#M147117
	
	Adapted code by Uwe Laubender.
	Original code by Dirk Becker
	for adding a "No Break" to the context menu when text is selected.
	Dirk Becker  Jun 9, 2009 3:43 PM (in response to Fritz Hansen)
	URL not available anymore, because this thread was not moved to the new forum in 2019.
*/

( function () {

	var miCopy = app.menus.itemByName("$ID/Main").menuElements.itemByName("$ID/Edit").menuElements.itemByName("$ID/Copy").getElements()[0]; // menuItem
	var miPaste = app.menus.itemByName("$ID/Main").menuElements.itemByName("$ID/Edit").menuElements.itemByName("$ID/Paste").getElements()[0]; // menuItem

	var atc = app.menus.itemByName( "$ID/RtMouseTable" ); // "$ID/RtMouseLayout" or "$ID/RtMouseText" or "$ID/RtMouseTable"

	try
	{

	  atc.menuItems.itemByName(miCopy.name).remove();
	  atc.menuItems.itemByName(miPaste.name).remove();

	} catch( ex ) {};

	atc.menuItems.add( miCopy.associatedMenuAction , LocationOptions.BEFORE , atc.submenus.itemByName("$ID/Insert") );
	atc.menuItems.add( miPaste.associatedMenuAction , LocationOptions.BEFORE , atc.submenus.itemByName("$ID/Insert") );

})();

 

Source:

https://community.adobe.com/t5/indesign-discussions/edit-right-click-menu-in-indesign/td-p/10527781

 

Regards,
Uwe Laubender

( ACP )

Likes

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