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

How do I get Menu path to a submenu using the C++ SDK?

Engaged ,
Dec 10, 2025 Dec 10, 2025

How do I get Menu path to a submenu using the C++ SDK?

I need to use it in IMenuCustomizationData::HideSubMenu(const PMString &menuPath).

 

In the script, you can retrieve menuItems and subMenus from the menu. How do you accomplish the same thing using the C++ SDK?

TOPICS
SDK
247
Translate
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 2 Correct answers

Mentor , Dec 10, 2025 Dec 10, 2025

When a new version comes along with many changes I run a menu filter and action filter that log their input to a file for further reference. Never needed it dynamically, looking at IMenuMgr that is a bit thin indeed. If other interfaces fail, you already mentioned scripts, e.g. learn how to build and execute a script request. Sometimes it also helps to know your tools such as debugger, instruments, activity viewer.

 

Translate
Engaged , Dec 14, 2025 Dec 14, 2025

So there are also things like IExtendScriptUtils and IUxpScriptUtils.

Utils<IUxpScriptUtils>()->RunScriptInEngine(
    "MyUXP", // engineName
    "let { app } = require(\"indesign\");\n"
    "let myDocument = app.documents.add();"
);

Utils<IUxpScriptUtils>()->DeleteUxpScriptEngine("MyUXP");

 

This one is easier.

Translate
Mentor ,
Dec 10, 2025 Dec 10, 2025

When a new version comes along with many changes I run a menu filter and action filter that log their input to a file for further reference. Never needed it dynamically, looking at IMenuMgr that is a bit thin indeed. If other interfaces fail, you already mentioned scripts, e.g. learn how to build and execute a script request. Sometimes it also helps to know your tools such as debugger, instruments, activity viewer.

 

Translate
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
Engaged ,
Dec 11, 2025 Dec 11, 2025

Thank you very much. That was very helpful.

I counted the number of MenuItems in the script and obtained that value.

do
{
	InterfacePtr<IScriptManager> iScriptManager(
		Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss)
	);
	if (iScriptManager == nil) break;

	InterfacePtr<IScriptEngine> iScriptEngine(
		iScriptManager->QueryDefaultEngine()
	);
	if (iScriptEngine == nil) break;

	InterfacePtr<IScriptRunner> iScriptRunner(iScriptEngine, UseDefaultIID());
	if (iScriptRunner == nil) break;

	// Dispatch a script.
	ScriptData scriptData_script("app.menus.item(95).menuItems.count();");
	ScriptRecordData scriptRecordData_arguments;
	ScriptData scriptData_return;
	PMString pMString_errorString;
	Utils<IScriptUtils>()->DispatchScriptRunner(
		iScriptRunner, // scriptRunner
		scriptData_script, // script
		scriptRecordData_arguments, // arguments
		scriptData_return, // result
		pMString_errorString, // errorString
		kTrue // showErrorAlert,
	);

	int32 int32_countNum;
	scriptData_return.GetInt32(&int32_countNum);

	PMString pMString_result;
	pMString_result.AsNumber(int32_countNum);

	CAlert::InformationAlert(pMString_result);

	// When a return value is not required.
	RunScriptParams runScriptParams(iScriptRunner);
	ErrorCode errorCode = iScriptRunner->RunScript(
		"alert('test');", runScriptParams
	);

} while (false);

 

Translate
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
Engaged ,
Dec 14, 2025 Dec 14, 2025
LATEST

So there are also things like IExtendScriptUtils and IUxpScriptUtils.

Utils<IUxpScriptUtils>()->RunScriptInEngine(
    "MyUXP", // engineName
    "let { app } = require(\"indesign\");\n"
    "let myDocument = app.documents.add();"
);

Utils<IUxpScriptUtils>()->DeleteUxpScriptEngine("MyUXP");

 

This one is easier.

Translate
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