Copy link to clipboard
Copied
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?
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.
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more