No internet connection
  1. Home
  2. How to

Closed Focus window is Minimizing Instead...

By Philip weinrobe @Philip_weinrobe
    2023-06-13 21:39:24.952Z

    hi genius people
    i am using this command to close the Strip Silence window, but it seems to be minimizing it instead, which is causing weird problems.

    // Close Strip Silence
        sf.ui.proTools.viewCloseFocusedFloatingWindow();
    

    any idea why? is there a better way to close this window?
    i could just use the close all windows command...

    • 4 replies
    1. P
      Philip weinrobe @Philip_weinrobe
        2023-06-13 21:43:40.262Z

        i'm using this whole script.
        i'd say most of the time i run it on a batch of tracks it minimizes the window before the last track is stripped, and then i can't get it to work right again.

        this is a new bug.

        // NOTE: Setup Strip Silence with your preferred settings before running this script
        //Activate Pro Tools
        sf.ui.proTools.appActivate();
        sf.ui.proTools.invalidate()
        
        function stripTheSilence(trackHeader) {
        
        
            //Select track
            trackHeader.trackSelect();
        
            //Scroll track into View
            trackHeader.trackScrollToView();
        
        
            // Select All Clips In Track
            sf.keyboard.press({
                keys: 'cmd+a'
            });
        
        
            // Click Strip Button
            sf.ui.proTools.windows.whoseTitle.is("Strip Silence").first.buttons.whoseTitle.is("Strip").first.mouseClickElement();
        
            // Create Fades On Clips
        
           // sf.keyboard.press({
           //     keys: 'f'
           // });
        
        
        }
        
        function main() {
            // Set Pro Tools frontmost
            sf.ui.proTools.appActivateMainWindow();
        
            //Get selected tracks
            const selectedTrackHeaders = sf.ui.proTools.selectedTracks.trackHeaders;
        
            // Declare stripSilenceWin Variable as Strip Silence Window
        
            var stripSilenceWin = sf.ui.proTools.windows.whoseTitle.is("Strip Silence").first;
        
            if (stripSilenceWin && stripSilenceWin.exists) {
                //Strip Silence IS open, do nothing
            } else {
                //Strip Silence is NOT open
                // Open Strip Silence
                sf.ui.proTools.menuClick({
                    menuPath: ['Edit', 'Strip Silence']
                });
                //    stripSilenceWin.getElement("AXTitleUIElement").elementWaitFor();
        
            }
        
            selectedTrackHeaders.forEach( trackHeader => {
                stripTheSilence(trackHeader)
            });
        
            // Close Strip Silence
            //sf.ui.proTools.viewCloseFocusedFloatingWindow();
            sf.ui.proTools.viewCloseFloatingWindows();
        
            // Select original Selected tracks
            sf.ui.proTools.trackSelectByName({ names: selectedTrackHeaders.map(t => t.normalizedTrackName) });
        
        }
        
        main();
        
        1. Kitch Membery @Kitch2023-06-13 22:13:08.267Z

          Hi @Philip_weinrobe

          Try instead using the following code to close the Strip Silence window.

          sf.ui.proTools.appActivateMainWindow();
          
          var stripSilenceWin = sf.ui.proTools.windows.whoseTitle.is("Strip Silence").first;
          
          stripSilenceWin.windowClose();
          

          I hope that helps.

          1. PPhilip weinrobe @Philip_weinrobe
              2023-06-14 18:00:01.214Z

              hmmm. replacing my lines 61 to 64 with this new code didn't change the way the script is bugging out.
              it still minimizes the window on the last selected track when I run it across multiple tracks.
              maybe some other part of the script is causing the window to minimize?

              1. Kitch Membery @Kitch2023-06-14 20:17:24.162Z

                Hi @Philip_weinrobe,

                I think the issue might have been that the main window of Pro Tools needed to be invalidated. Give this script a try. :-)

                function stripTheSilence(trackHeader) {
                    //Select track
                    trackHeader.trackSelect();
                
                    //Scroll track into View
                    trackHeader.trackScrollToView();
                
                    // Select All Clips In Track
                    sf.ui.proTools.menuClick({ menuPath: ["Edit", "Select All"] })
                
                    const stripSilenceWin = sf.ui.proTools.windows.whoseTitle.is("Strip Silence").first;
                    const stripButton = stripSilenceWin.buttons.whoseTitle.is("Strip").first
                
                    stripButton.mouseClickElement();
                
                    // Create Fades On Clips
                    //sf.keyboard.press({ keys: 'f', });
                }
                
                function main() {
                    //Activate Pro Tools
                    sf.ui.proTools.appActivateMainWindow();
                    sf.ui.proTools.mainWindow.invalidate();
                
                    //Get selected tracks
                    const selectedTrackHeaders = sf.ui.proTools.selectedTracks.trackHeaders;
                    const originalSelectedTrackNames = selectedTrackHeaders.map(t => t.normalizedTrackName);
                
                    // Strip Silence Window    
                    const stripSilenceWin = sf.ui.proTools.windows.whoseTitle.is("Strip Silence").first;
                
                    if (!stripSilenceWin.exists) {
                        // Open Strip Silence
                        sf.ui.proTools.menuClick({
                            menuPath: ['Edit', 'Strip Silence']
                        });
                
                        stripSilenceWin.elementWaitFor();
                    }
                
                    selectedTrackHeaders.forEach(trackHeader => {
                
                        stripTheSilence(trackHeader);
                    });
                
                    // Close Strip Silence
                    stripSilenceWin.windowClose();
                
                    // Select Original Selected tracks
                    sf.ui.proTools.trackSelectByName({
                        names: originalSelectedTrackNames,
                    });
                
                }
                
                main();
                

                I hope that helps!
                Rock on.