# \[Bug\] menuBarInfo not updated correctly (only after canvas focus)

**URL:** <https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859>\
**Category:** Photoshop\
**Tags:** bug\
**Created:** [June 26, 2022, 9:26pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859 "2022-06-26T21:26:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 26, 2022, 9:26pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/1 "2022-06-26T21:26:35Z")

</div>

Maybe I’m overlooking something, but it seems like the `menuBarInfo` property of the app isn’t updated correctly.

I have a function to toggle guide visibility and would like to know the current state of the menu command, but it keeps logging the same value even though the toggling works correctly:

```auto
const toggleGuideVisibility = () => {
  const guidesVisible = getAppProperty("menuBarInfo")
    .submenu.find(c => c.menuID === 9) // View
    .submenu.find(c => c.menuID === 59) // Show
    .submenu.find(c => c.command === 3503).checked // Guides
  console.log(guidesVisible)
  performMenuCommand(3503)
}

function getAppProperty(prop) {
  return require("photoshop").action.batchPlay([
    {
      _obj: 'get',
      _target: [{ _property: prop }, { _ref: 'application', _enum: 'ordinal', _value: 'targetEnum' }],
    },
  ], { synchronousExecution: true })[0][prop]
}

function performMenuCommand(commandID: number) {
  require("photoshop").core.performMenuCommand({ commandID });
}

```

Some further investigation showed that the menu seems to get updated **only** after the canvas gets focus again.

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 27, 2022, 10:52pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/2 "2022-06-27T22:52:17Z")

</div>

Just noticed that there’s also the Document property `guidesVisibility`, however this one is also always true no matter the actual visibility of the guides 😕

---

<div class="post-metadata">

**Author:** ![kbsanders](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kbsanders/32/2388_2.png) [@kbsanders](https://forums.creativeclouddeveloper.com/u/kbsanders)\
**Post date:** [December 18, 2022, 9:12am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/3 "2022-12-18T09:12:41Z")

</div>

@simonhenke Did you ever find a workaround for this issue?

I have just ran into this myself, trying to query the checked state of the `View > Show > Selection Edges` or the `View > Extras` menu item.

There appears to be some sort of caching mechanism going on behind the scenes.

If I query the `checked` state of the menu item during an `invokeCommand` action event for said menu item, the menu item’s checked state never changes to accurately reflect the menu’s current state.

However, I did notice that if I move the `menuBarInfo` batch play into a `setTimeout` to give myself enough time to open ANY submenu (File, Edit, Plugin’s Flyout, etc., does not matter) with my mouse, then when the timeout occurs and the batch play executes, the menu item WILL show the correct menu item checked state.

So it seems opening the menu bar with your mouse causes PS to invalidate and repopulate the `menuBarInfo` cache on the next query.

The way forward may be to discover some way to programmatically invalidate this cache, if possible.

---

<div class="post-metadata">

**Author:** ![kbsanders](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kbsanders/32/2388_2.png) [@kbsanders](https://forums.creativeclouddeveloper.com/u/kbsanders)\
**Post date:** [December 18, 2022, 1:57pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/4 "2022-12-18T13:57:02Z")

</div>

@kerrishotts Hi Kerri, are you aware of this cached `menuBarInfo` application property issue we seem to be encountering in this thread?

Do you know of some way to invalidate the cached object or force the property to refresh via code?

Or better yet, get to the `checked` menu item property more directly?

Ideally, it would be great if we could get all the menu properties (`enabled`, `checked`, `visible`) via the `psCore.getMenuCommandState(commandID)` API method instead of just `enabled` as it currently stands.

[https://developer.adobe.com/photoshop/uxp/2022/ps\_reference/media/photoshopcore/#getmenucommandstate](https://developer.adobe.com/photoshop/uxp/2022/ps_reference/media/photoshopcore/#getmenucommandstate)

Would appreciate any insight you have to offer, thanks!

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [December 19, 2022, 11:47am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/5 "2022-12-19T11:47:22Z")

</div>

I also didn’t find any workaround 😕 Would be nice if the menu states would be reliable.

---

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [December 19, 2022, 10:17pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/6 "2022-12-19T22:17:23Z")

</div>

Im wondering if @Erin_Finnegan may have an answer to this

---

<div class="post-metadata">

**Author:** ![Erin\_Finnegan](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/erin_finnegan/32/100_2.png) [@Erin\_Finnegan](https://forums.creativeclouddeveloper.com/u/Erin_Finnegan)\
**Post date:** [December 20, 2022, 2:52am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/7 "2022-12-20T02:52:47Z")

</div>

Bouncing this to @samgannaway

---

<div class="post-metadata">

**Author:** ![AnthonyK](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@AnthonyK](https://forums.creativeclouddeveloper.com/u/AnthonyK)\
**Post date:** [December 21, 2022, 1:31am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/8 "2022-12-21T01:31:05Z")

</div>

I’ve also noticed that there are times I need to run some unnecessary getter to give Ps time to catch up to what I actually want batchPlay to do. If I run the desired batchPlay too soon, it gets ignored. However, if I throw in the getter, then the batchPlay runs expected. And (surprise!) it looks like I use this then when I’m toggling selection edges on and off.

Here’s what I found works:

```auto
let m, currentToolOptions;
    for (m = 0; m < 3; m++) {  
        currentToolOptions = await batchPlay([
            //Get the currentToolOptions to slow things down a bit 
            { "_obj": "get", "_target": [{ "_property": "currentToolOptions" }, { "_ref": "application", "_enum": "ordinal", "_value": "targetEnum" }], "_options": { "dialogOptions": "dontDisplay" } }
        ],{ });   
    } 

```

So I run the getter 3 times and then Ps is finally ready and willing to toggle the selection edges appropriately.

Totally weird, but it’s a workaround that seems to work.

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [December 21, 2022, 7:06am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/9 "2022-12-21T07:06:55Z")

</div>

OK, this 3x getter should take couple of milliseconds at most. It reminded me of the old IE times, where we had to do something, that didn’t make sense at all, but it made things in JS work:

```auto
setTimeout(callback, 0)

```

That delay of 0 milliseconds did the magic 😃 Would that work here?

---

<div class="post-metadata">

**Author:** ![AnthonyK](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@AnthonyK](https://forums.creativeclouddeveloper.com/u/AnthonyK)\
**Post date:** [December 27, 2022, 9:51pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/10 "2022-12-27T21:51:44Z")

</div>

Interestingly, I’m finding that if I manually toggle menu items by clicking them with my mouse in the Ps menu, the “menuBarInfo” for that item changes when I log it out to the console. However, when I change it programmatically with

```auto
require("photoshop").core.performMenuCommand({ commandID });

```

The change does not register in the console. It’s the same value.

Keyboard shortcuts to toggle the Ps menu items aren’t picked up either.

Only actually going in and using a mouse on the menu to toggle items results in a change to the “menuBarInfo” that gets logged out.

What’s even more odd is that the “checked” property appears to be the opposite of what I’d expect. When the item is manually clicked to toggle it on, checked = false when I log out the “checked” property. And, when I manually toggle it off, checked = true.

---

<div class="post-metadata">

**Author:** ![kbsanders](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kbsanders/32/2388_2.png) [@kbsanders](https://forums.creativeclouddeveloper.com/u/kbsanders)\
**Post date:** [December 5, 2023, 3:27am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/11 "2023-12-05T03:27:45Z")

</div>

I’m still running into this issue a year later.

Has anyone yet discovered a way to force Photoshop to invalidate and refresh its `menuBarInfo` application property programmatically?

---

<div class="post-metadata">

**Author:** ![kbsanders](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kbsanders/32/2388_2.png) [@kbsanders](https://forums.creativeclouddeveloper.com/u/kbsanders)\
**Post date:** [December 5, 2023, 7:53am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/12 "2023-12-05T07:53:51Z")

</div>

Update: After hours of trying different things to invalidate `menuBarInfo` with no joy and finally digging through the internal UXP JavaScript for answers, I came across the following descriptor that does exactly what I need. It produces a real-time uncached status for a given menu item (commandID) including both the `enabled` and `checked` properties.

```auto
{
    _obj: 'uiInfo',
    _target: {
      _ref: 'application',
      _enum: 'ordinal',
      _value: 'targetEnum',
    },
    command: 'getCommandEnabled',
    commandID: <commandID>,
  }

```

Executing this in a BatchPlay returns a result similar to the following:

```auto
{
    "result": {
        "commandID": 1002,
        "enabled": true,
        "checked": true
    },
    "command": "getCommandEnabled",
    "dontRecord": true,
    "forceNotify": true
}

```

I don’t know if this is an undocumented descriptor or how well it is supported.  
If anyone has any further information, I would like to learn more about it.

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [December 5, 2023, 8:21am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/13 "2023-12-05T08:21:00Z")

</div>

> [@kbsanders](#):
>
> I don’t know if this is an undocumented descriptor

Are there any descriptors documented? Could you share a link to the ones that are documented? 🧐

---

<div class="post-metadata">

**Author:** ![kbsanders](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kbsanders/32/2388_2.png) [@kbsanders](https://forums.creativeclouddeveloper.com/u/kbsanders)\
**Post date:** [December 5, 2023, 8:48am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/14 "2023-12-05T08:48:45Z")

</div>

I suppose I meant documented in forum posts or usage examples. The only Google results I could find for `uiInfo` or `getCommandEnabled` dealt with `ActionReference` and `Action Manager`, which I believe is the legacy JSX scripting engine (pre UXP)?

For example:

> **[Check the availability of Save for web option](https://community.adobe.com/t5/photoshop-ecosystem-discussions/check-the-availability-of-save-for-web-option/m-p/10432981)**
>
> I want to check the availability Save for web option for Photoshop CC 2107, 2015.5 and 2014. I have found the script for only CC2017 as follows. var r = new ActionReference();  r.putEnumerated(stringIDToTypeID("application"),...

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [December 5, 2023, 2:21pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/15 "2023-12-05T14:21:59Z")

</div>

How about this? I think it should do the same thing but it is documented. [https://developer.adobe.com/photoshop/uxp/2022/ps\_reference/media/photoshopcore/#getmenucommandstate](https://developer.adobe.com/photoshop/uxp/2022/ps_reference/media/photoshopcore/#getmenucommandstate)

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [December 5, 2023, 2:23pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/16 "2023-12-05T14:23:51Z")

</div>

`get` and `multiGet` are documented: [https://developer.adobe.com/photoshop/uxp/2022/ps\_reference/media/batchplay/#multi-get](https://developer.adobe.com/photoshop/uxp/2022/ps_reference/media/batchplay/#multi-get)

---

<div class="post-metadata">

**Author:** ![kbsanders](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kbsanders/32/2388_2.png) [@kbsanders](https://forums.creativeclouddeveloper.com/u/kbsanders)\
**Post date:** [December 5, 2023, 8:30pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/17 "2023-12-05T20:30:31Z")

</div>

Unfortunately, `core.getMenuCommandState` returns a single boolean representing just the `enabled` state of the menu item.

Sometimes you want to know if a menu item is `checked` instead. (e.g. View \> Rulers)

Ideally they should have coded it to return both the `checked` and `enabled` states similar to the result that `getCommandEnabled` provides, but did not.

It’s also a bit frustrating that something called `getCommandEnabled` returns both `checked` and `enabled` while something called `getMenuCommandState` returns just `enabled`. The nomenclature is backwards.

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [December 5, 2023, 9:18pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/18 "2023-12-05T21:18:51Z")

</div>

Yes… when you are naming things as a programmer… you have to think 20 years ahead about all possible developments in the future because it can’t be changed later for compatibility reasons… 😃

---

<div class="post-metadata">

**Author:** ![pururu123](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@pururu123](https://forums.creativeclouddeveloper.com/u/pururu123)\
**Post date:** [July 21, 2024, 3:43am UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/19 "2024-07-21T03:43:11Z")

</div>

Thanks I was having the same problem, it solved it.

---

<div class="post-metadata">

**Author:** ![ssstoianov](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@ssstoianov](https://forums.creativeclouddeveloper.com/u/ssstoianov)\
**Post date:** [May 25, 2025, 4:45pm UTC](https://forums.creativeclouddeveloper.com/t/bug-menubarinfo-not-updated-correctly-only-after-canvas-focus/4859/20 "2025-05-25T16:45:54Z")

</div>

Man thank you for this. Works like a charm!
