No internet connection
  1. Home
  2. How to

Pro Tools; Setting 2 particular Groups to "Active"

By Reid Caulfield @Reid_Caulfield
    2021-07-16 20:30:40.529Z

    Hello all. Here's what I need to do

    1. Set 2 particular named Groups to "Active";
    2. However, while the names of the groups in question is mostly the same from session to session, part of the group name does change, and so I need to activate groups using only the part of the name that stays the same.

    Example:

    ENG 51 Work Grp

    I need to ignore the "ENG" because this changes session to session.

    Thank you for any help you can offer!

    Solved in post #2, click to view
    • 2 replies
    1. samuel henriques @samuel_henriques
        2021-07-17 06:33:43.782Z

        Hello Reid,

        This is an adaptation of Christian's script found here:
        Checking if the group is active or not #post-4

        in this line setGroupActive("51 Work Grp", true);

        It looks for a group with "51 Work Grp" included on name and true is meant to activate, you can use false to deactivate.
        So, in your example the group name is "ENG 51 Work Grp", " 51 Work Grp" is included on the name.

        I left two lines,

        setGroupActive("51 Work Grp", true);
        setGroupActive("52 Work Grp", true);
        

        for two groups, add as manny as you need.
        Hope it helps.

        
        /**
         * @param {string} groupName
         * @param {boolean} targetValue Set to true (active) or false (inactive)
         */
        function setGroupActive(groupName, targetValue) {
            let grp = sf.ui.proTools.mainWindow.groupListView.childrenByRole('AXRow').map(r => {
                let btn = r.childrenByRole('AXCell').allItems[1].buttons.first;
                return {
                    groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1],
                    btn,
                    isActive: btn.title.invalidate().value.indexOf('Active ') === 0,
                    row: r,
                };
            }).filter(g => g.groupName.includes(groupName))[0];
            if (!grp) throw `Group with name "${groupName}" was not found`;
            if (grp.isActive !== !!targetValue)
                grp.btn.elementClick();
        }
        
        setGroupActive("51 Work Grp", true);
        setGroupActive("52 Work Grp", true);
        
        Reply1 LikeSolution
        1. RReid Caulfield @Reid_Caulfield
            2021-07-17 17:31:10.283Z

            This works, Samuel. Thank you for you patience, I'm slowly understanding the construct.