No internet connection
  1. Home
  2. Script Sharing

Enable Automation of all Plugin parameters

By Sreejesh Nair @Sreejesh_Nair
    2024-11-10 08:33:25.721Z2024-12-11 21:07:45.841Z

    This script will enable all the parameters of all the plugin inserts on all the selected tracks. The way it works is to see if there are any parameters in the left part of the Plugin automation window and add it to the right. It then goes to the next radio button rather than opening all the plugins on the track. This is a much faster way. There is a change in Pro Tools 2024.10 where the plugin window name has changed from Plug-in to Plugin. This script works on all the versions.

    Edit: Found a robust way to select parameters thanks to @Kitch

    sf.ui.proTools.appActivate();
    sf.ui.proTools.invalidate();
    if (sf.ui.proTools.floatingWindows.whoseTitle.contains("Plug").exists) {
        sf.ui.proTools.floatingWindows.whoseTitle.contains('Plug').allItems.forEach(function (win) {
            try {
                win.windowClose();
            }
            catch (err) { }
        });
    }
    let selectedTracks = sf.ui.proTools.selectedTrackHeaders;
    let totalItems = selectedTracks.length;
    let processedItems = 0;
    let notificationID = sf.system.newGuid().guid;
    
    function findFirstActivePlugin(track) {
        const totalInserts = track.insertSelectorButtons.length;
        for (let i = 0; i < totalInserts; i++) {
            let button = track.insertSelectorButtons[i];
            if (button.exists && !button.invalidate().value.value.startsWith("inactive") && track.insertButtons[i].value.value !== "unassigned") {
                return i; // Return the index of the first active plugin
            }
        }
        return -1; // No active plugin found
    }
    
    function openPluginAutomationEnable() {
        sf.ui.proTools.pluginWindow.buttons.whoseTitle.contains("Automation enable").first.elementClick({ asyncSwallow: true });
        sf.wait({intervalMs: 200})
        sf.ui.proTools.pluginWindow.elementWaitFor({waitType: "Appear"})
    }
    
    function iterateAutomationInserts() {
        for (let i = 0; i < 10; i++) {
            let radioButton = sf.ui.proTools.windows.whoseTitle.contains("Automation").first.radioButtons.whoseTitle.is("Insert x").allItems[i];
    
            // Check if the radio button is active
            if (radioButton.isEnabled) {
                radioButton.elementClick();
                sf.ui.proTools.invalidate();
                const pluginAutomationWindow = sf.ui.proTools.windows.whoseTitle.is("Plugin Automation").first;
                const table = pluginAutomationWindow.tables.whoseTitle.is("TextGridView").first;
                const rows = table.childrenByRole("AXColumn").first.children.map(e => e);
                if (rows.length) rows[0].childrenByRole("AXCell").first.mouseClickElement({isOption: true});
    
                // Check if "Add >>" button is enabled, then select all and click "Add >>"
                let addButton = pluginAutomationWindow.buttons.whoseTitle.is("Add >>").first;
                if (addButton.isEnabled) {
                    addButton.elementClick();
                }
            }
        }
    }
    function finalizeAutomationSettings() {
        sf.ui.proTools.windows.whoseTitle.contains("Automation").first.buttons.whoseTitle.is("OK").first.elementClick();
    }
    
    // Main logic
    for (let i = 0; i < selectedTracks.length; i++) {
        let track = selectedTracks[i];
        let firstActivePluginIndex = findFirstActivePlugin(track);
    
        if (firstActivePluginIndex !== -1) {
            // Open the first active plugin
            track.insertButtons[firstActivePluginIndex].elementClick();
            sf.wait({intervalMs: 200})
            sf.ui.proTools.floatingWindows.whoseTitle.contains("Plug").first.elementWaitFor({ waitType: "Appear" })
            // Wait until the window opens or skip after some attempts
            let attempts = 0;
            while (attempts < 10) {
                let pluginWin = sf.ui.proTools.pluginWindow;
                if (pluginWin) {
                    openPluginAutomationEnable();
                    iterateAutomationInserts();
                    finalizeAutomationSettings();
                    break;
                }
    
                sf.wait({ intervalMs: 100 });
                attempts++;
            }
        }
    
        // Update notification with progress
        sf.interaction.notify({
            uid: notificationID,
            title: "Enabling Plugin Parameter",
            progress: (++processedItems) / totalItems,
            message: `Processing Track: ${processedItems} of ${totalItems}`
        });
    }
    sf.ui.proTools.pluginWindow.windowClose();
    alert("Done!")
    
    • 8 replies
    1. E
      Eli Crews @Eli_Crews
        2024-11-25 21:47:51.836Z

        Hi Sreejesh, thanks for creating this, I tried to copy and change it so that it would only enable automation parameters on the currently open plugin, but couldn't figure it out. Any chance you could quickly create a version of your script for that purpose? Thanks in advance!
        Eli

        1. Here's the quick and dirty way:

          1. Chris Shaw @Chris_Shaw2024-11-25 22:08:15.954Z2024-11-25 22:34:54.650Z

            As a script: (this will toggle / enable all parameters on focused / last focused plugin window):

            sf.ui.proTools.appActivateMainWindow();
            
            const topPluginWindow = sf.ui.proTools.floatingWindows.invalidate().filter(w => w.title.value.startsWith("Plug"))[0];
            
            if (topPluginWindow) {
                topPluginWindow.elementRaise()
                topPluginWindow.buttons.invalidate().whoseTitle.is("Plugin Automation enable").first.mouseClickElement({
                    isOption: true,
                    isControl: true,
                    isCommand: true
                })
            } else {
                sf.interaction.notify({
                    title: "Toggle /Enable automation on all pluign parameters",
                    message: "No plugin open"
                })
            }
            
            1. EEli Crews @Eli_Crews
                2024-11-25 22:33:58.858Z

                Amazing, thanks, Chris! Didn't realize you could ctrl/opt/cmd click it, thanks for alerting me to that (and for the script)

                1. You can also ctrl/opt/cmd click individual parameters too

          2. In reply toSreejesh_Nair:
            Kitch Membery @Kitch2024-12-11 21:55:50.343Z

            Hi @Sreejesh_Nair,

            So great to meet you at the SoundFlow Hangout today.

            I worked out a way of removing the mouseclick that was needed for adding the parameters. Not sure if it's faster but it may be more stable as it does not need to use Mouse simulation.

            function addAllPluginAutomationParameters() {
                const pluginAutomationWindow = sf.ui.proTools.windows.whoseTitle.is("Plugin Automation").first;
                const table = pluginAutomationWindow.tables.whoseTitle.is("TextGridView").first;
            
                const getRows = () => table.childrenByRole("AXColumn").first.invalidate().children;
            
                pluginAutomationWindow.radioButtons.whoseTitle.is("Insert x").forEach(btn => {
                    // Click the Insert radio button
                    btn.elementClick();
            
                    let rows = getRows();
            
                    while (rows.length > 0) {
                        const firstRow = rows[0]
                        const firstRowCell = firstRow.childrenByRole("AXCell").first;
            
                        // Select the rows
                        firstRowCell.elementClick();
            
                        // Refresh the rows within the while loop
                        rows = getRows();
                    }
                });
            }
            
            sf.ui.proTools.appActivateMainWindow();
            
            addAllPluginAutomationParameters();
            

            Let me know if it works for you. And see you next SoundFlow Hangout! :-)

            FYI @Chris_Shaw, @raphaelsepulveda, @Sam_Ada, @Mike_Wax

            1. SSreejesh Nair @Sreejesh_Nair
                2024-12-11 22:13:54.478Z

                This is cool!! I'll try this out. Just to ask, there is no way to have an elementClick() with isOption: = true is there?

                1. Kitch Membery @Kitch2024-12-11 22:33:05.499Z

                  As far as I know, the only way to do so is by invoking a mouse click. I'm not sure it can be done with elementClick. I'll take a look and will report back if I find a way though. :-)