Answered
Can't get scriptMenuAction to properly run (…the object no longer exists…)
Hi everyone,
Trying to execute a menu addition and at the moment the event handler function is executed, I get the "
The requested action could not be completed because the object no longer exists". Thought I made something wrong but even the sample script from the official documentation throws the same error.
Tested on CC23, 22 et 19 with no luck.
This is the official sample from doc:
var mySampleScriptAction = app.scriptMenuActions.add("Display Message");
var myEventListener = mySampleScriptAction.eventListeners.add("onInvoke",
function () { alert("This menu item was added by a script."); });
//If the submenu "Script Menu Action" does not already exist, create it.
try {
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.item("Script Menu Action");
mySampleScriptMenu.title;
}
catch (myError) {
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.add("Script Menu Action");
}
var mySampleScriptMenuItem = mySampleScriptMenu.menuItems.add(mySampleScriptAction);
I saw this post but it didn't help much.
Is it just me?
Loic