in my search I couldn’t find a way to set the checked
value of a menu item so I went with 2nd best thing.
I get the current state of the menu item and and toggle only if needed.
async function showExtras(state){
let extrasIsChecked = (await batchPlay([{
"_obj": "get",
"_target": [{"_property": "menuBarInfo"},{"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"},]
}], {}))[0].menuBarInfo.submenu.find( m => m.name == "View").submenu.find( m => m.name == "Extras").checked
if (extrasIsChecked != state) {
await core.performMenuCommand({commandID: 3500})
}
}
that function can be used as follows:
//Show Extras
await showExtras(true);
//Hide Extras
await showExtras(false);
EDIT:
as pointed out the previous function may fail on non English versions of PS, so here’s another way using IDs instead of names:
async function showExtras(state){
let extrasIsChecked = (await batchPlay([{
"_obj": "get",
"_target": [{"_property": "menuBarInfo"},{"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"},]
}], {}))[0].menuBarInfo.submenu.find( m => m.menuID== 9).submenu.find( m => m.command == 3500).checked
if (extrasIsChecked != state) {
await core.performMenuCommand({commandID: 3500})
}
}