No internet connection
  1. Home
  2. How to

isMenuChecked Vs window is opened but not focused "-"

By samuel henriques @samuel_henriques
    2021-04-11 11:27:54.874Z

    hello everyone,

    this code will get me the items that are checked from the window menu:

    let menuItems = sf.ui.proTools.getMenuItem("Window").popupMenuFetchAllItems().menuItems
    let menuEnabled = menuItems.filter(x => x.element.isMenuChecked) 
    sf.ui.proTools.appActivateMainWindow()
    log(menuEnabled)
    

    I'll get the ones with a √, how do I filter the ones with "-"?
    In this example, Video and Color Palette?

    Thank you so much

    Solved in post #2, click to view
    • 2 replies
    1. Dustin Harris @Dustin_Harris
        2021-04-11 13:22:35.097Z

        @Kitch came up with this gem:

        sf.ui.proTools.appActivateMainWindow();
        
        const menuItems = sf.ui.proTools.getMenuItem('Window').popupMenuFetchAllItems({
            dismissMenu: true,
        }).menuItems;
        
        const menuItemsInfo = menuItems.map(mi => ({
            path: mi.path,
            element: mi.element,
            isSelected: mi.element.isMenuChecked,
            hasDash: mi.element.getString('AXMenuItemMarkChar') === ('-'),
        }));
        
        let dashedMenuItems = menuItemsInfo.filter(mi => mi.hasDash);
        
        log(dashedMenuItems);
        
        Reply2 LikesSolution
        1. samuel henriques @samuel_henriques
            2021-04-11 16:19:11.013Z

            right on!! Thank you so much @Dustin_Harris and @Kitch,

            this i what i'm working on, It gets the enabled and disabled items from pro tools menus to an array of paths and you can set them back to original state later.