How can I programmatically enable and disable Extras?

I did try running the code you gave as-is and it didn’t seem to work for me.

also make sure that checked is returning the correct value. strangely in my tests sometimes it reported the opposite of visible state.

I’m experiencing this too. It’s really strange. I got the code to work… kind of. But It’s not reliable.

If I disable extras and then immediately go to the view menu - it will still show extras as enabled.

But if I click anywhere in the document or change tools and then go back to the view menu, it shows extras disabled. The same behavior occurs if I enable extras. For some reason, the change doesn’t update/propagate immediately.

It’s as if I need to force a refresh of the application “state” somehow after calling core.performMenuCommand({ commandID: 3500 });

Anyway, here’s my half-working code:

const { executeAsModal } = require("photoshop").core;
const { batchPlay } = require("photoshop").action;
const app = require('photoshop').app;
const core = require('photoshop').core;

async function showExtras(toggle) {
    const batchCommands = {
        _obj: "get",
        _target: [
                _property: "menuBarInfo"
                _ref: "application",
                _enum: "ordinal",
                _value: "targetEnum"
    let state = (await require('photoshop').action.batchPlay([batchCommands], {}));
    let viewMenu = (state[0].menuBarInfo.submenu.find((m) => == 'View'));
    let extrasMenu = (viewMenu.submenu.find((m) => == 'Extras'));
    let extrasIsChecked = extrasMenu.checked;

    if (extrasIsChecked != toggle) {
        core.performMenuCommand({ commandID: 3500 });

document.getElementById("btnDisableExtras").addEventListener('click', async () => {
    await showExtras(false);

document.getElementById("btnEnableExtras").addEventListener('click', async () => {
    await showExtras(true);

If anyone knows what the problem is, a solution would be greatly appreciated!



Here’s a screen recording of what I’m talking about with regards to the performMenuCommand not working immediately:

It’s most likely because menu states are not updated until user interacts with the menu. For example, if menu is altered in any way via API (some item changes checked state), API will return old state until user clicks on any menu item to expand it. IIRC this was discussed briefly on some other topic here, but I doubt I’ll be able to find it quickly

It doesn’t return the new state when I click on/expand a menu item. To show the new state, all I have to do is click somewhere in the document and then reopen the menu. But if I don’t click (or otherwise interact with the document) - the new state isn’t shown. This is demonstrated in the video I posted above.

Maybe I’m misunderstanding?

Edit: Do you think that PhotoshopCore.redrawDocument could be relevant here? Maybe calling this immediately after altering the menu state?

Could be. I didn’t test this myself. I remember I saw a comment about this. Worth a try to redraw IMO. If it won’t help, just remove :slight_smile:

@Karmalakas Unfortunately I don’t think a redraw is helping… :frowning:
Putting here for reference, the bug/behaviour is discussed in this other ticket