Check menubar item disabled status then if/else condition

Is there a way to check the status of a menubar item whether it's enabled or disabled? ChatGPT only gave me a script that returns true or false in the script result but I don't know how or where to save the returned value and use that for If condition action.

Here's the script:

tell application "System Events"
    tell process "Figma"
        set menuItemEnabled to (enabled of menu item "Go to Main Component" of menu "Main Component" of menu item "Main Component" of menu "Object" of menu bar 1)
    end tell
end tell
return menuItemEnabled

Thank you.

@Andreas_Hegenberg Hi, is there a better way to do this? I'm not sure I explained it very well. Determine if menubar item is disabled, then do this action. Otherwise, do this action. Stuff like that.

For example, in Figma, if I press a custom trigger — Opt+C and this menu item is disabled →

...BTT will detect this "Return to instance" button and click it :thinking:

I think this could save me from having to assign two shortcuts to each of them.

You can do it like this:

async function someJavaScriptFunction() {

    let menuItemDetailsString =   await get_menu_item_details("Edit;Cut");
    let menuItemDetails = JSON.parse(menuItemDetailsString);
     return menuItemDetails.enabled;
}

This would check the enabled state of the Edit => Cut item. You can also get the "checked" state via .checked

1 Like

Oh my god it works! I was gonna ask why when doing the script test run it always returns false but I don't think that matters. Thank you :slight_smile:

if you click the run button while BTT is frontmost, it will try to get the details from BTT‘s menubar. You can click the „run script“ button while pressing cmd, then BTT will stay in background

1 Like