No internet connection
  1. Home
  2. How to

script to open protools with a pre-defined engine

By Les Cooper @Les_Cooper
    2022-12-05 19:09:03.472Z

    I run Protools on a laptop that goes between being connected to a hub and an audio interface in my studio and running remote in various locations. I'd love to have a script that will open protools with a pre-defined engine for when I plug into my hub. Often, it will open with whatever the last used audio engine was so I have to change the engine and restart the session.
    Ideally, the script would launch Protools with the same behavior as launching with the 'n' key held down to launch the choose engine dialog and then select my audio interface which I would define in a variable as part of the script.

    • 7 replies
    1. Mitch Willard @Mitch_Willard
        2022-12-06 00:31:35.461Z2022-12-06 04:35:24.794Z

        Hi @Les_Cooper,

        You can just adjust the playback engine after launching Pro Tools, instead of writing a function to hold down 'n' on launch.

        try this:

        function adjustPlaybackEngine() {
            if (!sf.ui.proTools.isRunning) {
        
                function waitForPtLaunch() {
        
                    while (!sf.ui.proTools.invalidate().hasValidUI) {
                        sf.wait({ intervalMs: 200 })
                    }
                    for (var i = 0; i < 10; i++) {
                        sf.ui.proTools.waitForNoModals();
                    }
                }
        
                var playbackEngineArray = ['Universal Audio Thunderbolt', 'MacBook Pro Speakers'] ////Add any additional PLAYBACK ENGINE settings to here.
                var selectedPaybackEngine = sf.interaction.popupSearch({
                    title: "Select Playback Engine",
                    items: playbackEngineArray.map(p => ({
                        name: p,
                    })),
                    columns: [
                        { name: 'Please Select Playback Engine', key: 'name', width: 80 },
                    ]
                }).item.name;
        
                sf.app.launch({
                    path: "/Applications/Pro Tools.app",
                });
        
                sf.interaction.displayDialog({
                    prompt: 'Please wait for Pro Tools to Load,\n\nThe Playback Engine "' + selectedPaybackEngine + '" will be selected after launching Pro Tools\n\nThis dialog will disappear after a few seconds.',
                    title: 'PRO TOOLS IS LOADING',
                    giveUpAfterSeconds: 10,
                }).button
        
                waitForPtLaunch();
        
                sf.ui.proTools.menuClick({
                    menuPath: ['Setup', 'Playback Engine...']
                });
        
                let playbackEngineDlg = sf.ui.proTools.windows.whoseTitle.is("Playback Engine").first;
        
                playbackEngineDlg.elementWaitFor({
                    waitType: 'Appear',
                    timeout: 1000,
                    pollingInterval: 50
                });
        
                if (playbackEngineDlg.popupButtons.first.value.value != selectedPaybackEngine)
                    playbackEngineDlg.popupButtons.first.popupMenuSelect({
                        menuPath: [selectedPaybackEngine],
                    });
        
                playbackEngineDlg.buttons.whoseTitle.is("OK").first.elementClick();
        
                playbackEngineDlg.elementWaitFor({
                    waitType: 'Disappear',
                    timeout: 1000,
                    pollingInterval: 50
                });
        
                alert('Your Playback Engine has been set to:\n\n' + selectedPaybackEngine + '.')
        
            };
        };
        
        adjustPlaybackEngine();
        
        

        Cheers

        Mitch

        1. LLes Cooper @Les_Cooper
            2022-12-06 15:26:38.555Z

            Hey @Mitch_Willard

            First off, thank you so much for this. Too cool!

            I'm wondering if it would be possible to amend this a bit for some other situations.
            I'd like to be able to have a version where it chooses 'Universal Audio Thunderbolt' automatically - without any additional dialogs. This way, I could make a few different versions with different engines to put on a deck.
            Thanks again Mitch!
            Les

            1. Mitch Willard @Mitch_Willard
                2022-12-06 21:21:26.479Z

                Super easy @Les_Cooper

                Will get it to you shortly, will be in front of a computer soon.

                Mitch

                1. Mitch Willard @Mitch_Willard
                    2022-12-06 21:43:10.777Z

                    Here you go @Les_Cooper,

                    Just replace 'Universal Audio Thunderbolt' with whichever Playback Engine setting you'd like to use.

                    function adjustPlaybackEngine(selectedPlaybackEngine) {
                        if (!sf.ui.proTools.isRunning) {
                    
                            function waitForPtLaunch() {
                    
                                while (!sf.ui.proTools.invalidate().hasValidUI) {
                                    sf.wait({ intervalMs: 200 })
                                }
                                for (var i = 0; i < 10; i++) {
                                    sf.ui.proTools.waitForNoModals();
                                }
                            }
                    
                            sf.app.launch({
                                path: "/Applications/Pro Tools.app",
                            });
                    
                            sf.interaction.displayDialog({
                                prompt: `Please wait for Pro Tools to Load,\n\nThe Playback Engine "${selectedPlaybackEngine}" will be selected after launching Pro Tools\n\nThis dialog will disappear after a few seconds.`,
                                title: 'PRO TOOLS IS LOADING',
                                giveUpAfterSeconds: 10,
                            }).button
                    
                            waitForPtLaunch();
                    
                            sf.ui.proTools.menuClick({
                                menuPath: ['Setup', 'Playback Engine...']
                            });
                    
                            let playbackEngineDlg = sf.ui.proTools.windows.whoseTitle.is("Playback Engine").first;
                    
                            playbackEngineDlg.elementWaitFor({
                                waitType: 'Appear',
                                timeout: 1000,
                                pollingInterval: 50
                            });
                    
                            if (playbackEngineDlg.popupButtons.first.value.value != selectedPlaybackEngine)
                                playbackEngineDlg.popupButtons.first.popupMenuSelect({
                                    menuPath: [selectedPlaybackEngine],
                                });
                    
                            playbackEngineDlg.buttons.whoseTitle.is("OK").first.elementClick();
                    
                            playbackEngineDlg.elementWaitFor({
                                waitType: 'Disappear',
                                timeout: 1000,
                                pollingInterval: 50
                            });
                    
                            alert(`Your Playback Engine has been set to:\n\n'${selectedPlaybackEngine}'.`)
                    
                    
                        };
                    };
                    
                    adjustPlaybackEngine('Universal Audio Thunderbolt'); ////Replace 'Universal Audio Thuderbolt' with desired PLAYBACK ENGINE setting here.
                    
                    

                    Thanks

                    Mitch

                    1. LLes Cooper @Les_Cooper
                        2022-12-06 21:54:39.575Z

                        Too cool!
                        Thanks again Mitch.

                2. J
                  In reply toLes_Cooper:
                  Jonathan Dakers @Jonathan_Dakers
                    2024-12-04 07:48:31.697Z

                    Hi! This script isn't working for me, running Pro Tools 2024.10 in MacOS sequoia. Pro Tools opens, a box pops up saying it will select the right engine, but once Pro Tools is open nothing happens. Any ideas?

                    edit: Okay now when I opened a project the prompt came up saying the playback engine had been set. Maybe the script is waiting for something that only gets triggered when a project is open?

                    1. J2
                      In reply toLes_Cooper:
                      Jake Morton @Jake_Morton
                        2025-06-03 14:38:21.449Z

                        Is it possible to expand this script to auto-close Pro Tools popups?

                        Hey all,

                        First off — big thanks to Mitch for the script above. You've already saved me a huge amount of time!

                        I'm wondering if this approach can be extended to automatically handle and dismiss common Pro Tools popup dialogs like:

                        “You can’t use your UAD plugin XYZ.”

                        “This plugin has been deactivated.”

                        “Would you like to submit a crash report?”

                        “The original MIDI device could not be located.”

                        Or those dreaded Kontakt instrument error messages…

                        Basically, any of the annoying interruptions that occur during session load or startup.

                        I've gotten so used to these interruptions that I've resigned myself to never leaving my desk during a session load. Sometimes I'm interrupted 5–10 times before a session even opens — more if I’ve forgotten to connect the UAD Satellite or I’m loading a large session.

                        What puzzles me is that a few of Avid’s competitors don’t seem to suffer from this same issue, at least not with the same level of frequency or friction.

                        To some extent, I understand the risk of baking auto-dismissals into session startup. But in practice, I’m confident I’d hear if anything was off during playback or when printing a mix — so for me, it’s a worthwhile trade-off.

                        Attached are a couple of screenshots of the types of dialogs I’m referring to:

                        Would love to know if anyone's had success creating a broader catch-all for these alerts — or if it's even advisable. It would seriously streamline session startup and reduce the number of restarts caused by these disruptions.

                        Appreciate the thoughts in this thread already — looking forward to hearing more.

                        Cheers!