No internet connection
  1. Home
  2. How to

What is the best script to use to wait for the Bounce To Mix window to close and then continue?

By John Costello @John_Costello
    2020-11-22 18:33:03.502Z

    Heya friends!

    So this is part of my dream script! When I'm done with a song I need to create mixes in the normal PT bounce folder. FYI my mixes have analog gear on them so my bounces need to be in real time... I have already made seperate scripts for Bounce Full, Bounce Instrumental, Bounce 16-44 (For distribution.) and Commit Stems. These are all cool scripts that utilize the new preset commands in the Bounce To Mix window, and the amazing Scheps Commit script. Now I would like to chain them all together!!! So if I was able to have a wait for the Bounce To Mix window to close script inbetween each bounce, well I could have a nice walk or exercise while my hard working computer would render all the files I need to complete the mix process. The help I recieve here is amazing and I really appreciate it!

    • 45 replies

    There are 45 replies. Estimated reading time: 46 minutes

    1. Kitch Membery @Kitch2020-11-23 20:09:00.490Z

      Hi @John_Costello,

      Can you share the script that you have so far?... that way we'll be able to see what needs to be added at the end of each script to be able to chain them together.

      Rock on!

      1. John Costello @John_Costello
          2020-11-23 21:18:54.783Z

          1st Bounce
          Full Mix

          
          sf.ui.proTools.menuClick({
              menuPath: ["File","Bounce Mix..."],
          });
          sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.buttons.whoseTitle.is('Preset Toggle').first.elementClick();
          
          

          Would be great if I could enter the title like in your very clever script Kitch! Also this script does not trigger the bounce as I need to input the name.

          2nd Bounce
          Instrumental

          
          sf.ui.proTools.trackGetByName({ name: "Vox Master", makeVisible: true }).track.trackSetMute({
              targetValue: "Enable",
          });
          
          sf.ui.proTools.menuClick({
              menuPath: ["File","Bounce Mix..."],
          });
          
          sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.buttons.whoseTitle.is('Preset Toggle').first.elementClick();
          
          sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.textFields.whoseTitle.is('').first.elementClick();
          
          sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.textFields.whoseTitle.is('').first.elementClick();
          
          sf.keyboard.press({
              keys: "down",
          });
          
          sf.keyboard.type({
              text: "-Inst",
          });
          
          sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.buttons.whoseTitle.is('Bounce').first.windowClose();
          
          sf.ui.proTools.windows.whoseTitle.is('MP3').first.buttons.whoseTitle.is('OK').first.windowClose();
          
          

          This script mutes my vocal stem and crudely appends "-Inst" to the file name. This script activates the bounce.

          3rd Bounce
          16-44

          
          sf.ui.proTools.trackGetByName({ name: "Vox Master", makeVisible: true }).track.trackSetMute({
              targetValue: "Disable",
          });
          
          sf.ui.proTools.menuClick({
              menuPath: ["File","Bounce Mix..."],
          });
          
          sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.buttons.whoseTitle.is('Preset Toggle').allItems[1].elementClick();
          
          sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.textFields.whoseTitle.is('').first.elementClick();
          
          sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.textFields.whoseTitle.is('').first.elementClick();
          
          sf.keyboard.press({
              keys: "down",
          });
          
          sf.keyboard.type({
              text: " 16-44",
          });
          
          sf.keyboard.press({
              keys: "return",
          });
          

          This script un-mutes the vocal stem from the previous script and crudely appends the title with " 16-44".

          4th Commit Stems

          sf.soundflow.runCommand({
              commandId: 'user:ckfldmfi900002p10aqtdyo1z:ckfjjq34x00030y103bt2x0cg',
              props: {
                  commitOrFreeze: "Commit",
                  insertChoice: "J",
                  commitRoutingFolders: true,
                  multipleTracksProcessMode: "As a Group",
                  commitTarget: "Edit Selection",
                  commitAction: "Do Nothing",
                  commitConsolidateClips: false,
                  commitOffline: false,
              }
          });
          
          sf.soundflow.runCommand({
              commandId: 'user:ckfhimahc000g8n100ey7v88x:ckdv1td13000dyq10taeszpsg',
              props: {
                  windowEnum: "Edit",
              }
          });
          
          sf.ui.proTools.clipConsolidate();
          
          sf.wait({
              intervalMs: 2000,
          });
          
          sf.keyboard.press({
              keys: "cmd+shift+k",
          });
          

          This is the final script where if the stems were selected correctly, it will commit the stems, consolidate the clips (So they all start from the beginning.) and then crudely invoke the export dialog box.

          Would be great if I could tell the export window to use the current bounce folder as the directory to export the files.

          Well there it is in a nutshell! My dream script, my automated assistant...

          There is one more thing...

          Before all is said and done it would be great to launch messages and send me a quick text...

          I already know I'm crazy!

          Thank you for helping me so much!

          JC3

          1. John Costello @John_Costello
              2020-11-23 22:19:35.079Z

              The Text Me Script

              sf.file.open({
                  path: "/System/Applications/Messages.app",
              });
              
              sf.wait();
              
              sf.keyboard.press({
                  keys: "cmd+n",
              });
              
              sf.keyboard.type({
                  text: "123456",
              });
              
              sf.keyboard.press({
                  keys: "return",
              });
              
              sf.keyboard.type({
                  text: "Your Mixes are bounced!",
              });
              
              sf.keyboard.press({
                  keys: "return",
              });
              
              1. Kitch Membery @Kitch2020-11-23 22:21:02.915Z

                Probably best not to share your phone number on here, John Hahahaha.

                1. John Costello @John_Costello
                    2020-11-23 22:28:15.532Z

                    Yeah, anyone can call me, I'm a publisher! LOL!

                2. In reply toJohn_Costello:
                  Kitch Membery @Kitch2020-11-23 22:22:03.104Z

                  What are the commands referenced in the 4th step?

                  1. John Costello @John_Costello
                      2020-11-23 22:27:33.839Z

                      4th Step is:

                      Commit Selected Tracks - Sheps
                      Consolidate Clip
                      Export Clips as Files (To bounce folder. Not yet in script.)

                    • In reply toJohn_Costello:
                      Kitch Membery @Kitch2020-11-24 01:28:08.163Z2020-11-24 01:48:17.099Z

                      Hi John,

                      So, here are some tips for future scripts... whenever waiting for audio to process instead of using wait times like this;

                      sf.wait({
                          intervalMs: 2000,
                      });
                      

                      Use wait for modals;

                      sf.ui.proTools.waitForNoModals();
                      

                      Also instead of using keyboard simulation like this;

                      sf.keyboard.press({
                          keys: "cmd+shift+k",
                      });
                      

                      It's better to use menu selections, UI elements or Popup menus. So for this example it would be better to use the clips list popup menu to select "Export Clips as Files..." like this;

                      sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Clip List').first.popupMenuSelect({
                          menuPath: ["Export Clips as Files..."],
                      });
                      

                      I've put together a little somthing that does not include the export section at the end but this should get you a fair way through. Note: I've not tested the "Commit Stems" part of the script either.

                      Be sure to change up the first 8 lines for customization;

                      //Bounce Variables
                      const bounceDirectory = 'Bounced Files/';
                      const bounceSource = 'MacBook Pro Speakers 1-2(Stereo)';
                      
                      //For sending text message;
                      const recipientPhoneNumber = '9999999999';
                      const senderIcloudEmail = 'email@email.com';
                      const messageText = 'Your Epic bounce script has finished. Time to get back to the studio.';
                      
                      const bounceWin = sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first;
                      
                      function maximiseBounceWindow() {
                          const bounceWin = sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first;
                      
                          const audioPanel = bounceWin.groups.whoseTitle.is('Audio').first;
                      
                          function openAudioPanel() {
                              if (audioPanel.buttons.whoseTitle.is('Collapser').exists) {
                                  audioPanel.buttons.whoseTitle.is('Collapser').first.elementClick();
                              }
                          }
                          const locationPanel = bounceWin.groups.whoseTitle.is('Location').first;
                      
                          function openLocationPanel() {
                              if (locationPanel.buttons.whoseTitle.is('Collapser').exists) {
                                  locationPanel.buttons.whoseTitle.is('Collapser').first.elementClick();
                              }
                          }
                      
                          switch (bounceWin.frame.h) {
                              case 268:
                                  openAudioPanel();
                                  openLocationPanel();
                                  break;
                              case 406:
                                  openLocationPanel();
                                  break;
                              case 393:
                                  openAudioPanel();
                                  break;
                          }
                      }
                      
                      function doBounce(bounceSettings) {
                          const { bounceName, bounceSuffix, trackToMute, bounceSource, presetNum, bounceDirectory,
                       } = bounceSettings;
                      
                          sf.ui.proTools.trackGetByName({
                              name: trackToMute,
                              makeVisible: true
                          }).track.trackSetMute({
                              targetValue: "Enable",
                          });
                      
                          sf.ui.proTools.menuClick({ menuPath: ["File", "Bounce Mix..."], });
                      
                          bounceWin.elementWaitFor();
                      
                          maximiseBounceWindow();
                      
                          bounceWin.buttons.whoseTitle.is('Preset Toggle').allItems[presetNum - 1].elementClick();
                      
                          bounceWin.textFields.first.elementSetTextFieldWithAreaValue({
                              value: bounceName + ' - ' + bounceSuffix,
                          });
                      
                          const locationPanel = bounceWin.groups.whoseTitle.is('Location').first;
                      
                          if (locationPanel.textFields.first.value.invalidate().value !== bounceDirectory) {
                              locationPanel.textFields.first.elementSetTextFieldWithAreaValue({ value: bounceDirectory });
                          }
                      
                          bounceWin.buttons.whoseTitle.is('Bounce').first.elementClick();
                      
                          bounceWin.elementWaitFor({ waitType: 'Disappear' })
                      
                          const mp3Window = sf.ui.proTools.windows.whoseTitle.is('MP3').first;
                      
                          if (mp3Window.buttons.whoseTitle.is('OK').first.exists) {
                              mp3Window.buttons.whoseTitle.is('OK').first.windowClose();
                          };
                      
                          mp3Window.elementWaitFor({ waitType: 'Disappear' })
                      
                          sf.ui.proTools.waitForNoModals();
                      }
                      
                      function sendTextMessage() {
                          sf.system.execAppleScript({
                              script: `
                              tell application "Messages"
                                  send "${messageText}" to buddy "${recipientPhoneNumber}" of service "E:${senderIcloudEmail}"
                              end tell`
                          });
                      }
                      
                      function commitStems() {
                          sf.soundflow.runCommand({
                              commandId: 'user:ckfldmfi900002p10aqtdyo1z:ckfjjq34x00030y103bt2x0cg',
                              props: {
                                  commitOrFreeze: "Commit",
                                  insertChoice: "J",
                                  commitRoutingFolders: true,
                                  multipleTracksProcessMode: "As a Group",
                                  commitTarget: "Edit Selection",
                                  commitAction: "Do Nothing",
                                  commitConsolidateClips: false,
                                  commitOffline: false,
                              }
                          });
                      
                          sf.soundflow.runCommand({
                              commandId: 'user:ckfhimahc000g8n100ey7v88x:ckdv1td13000dyq10taeszpsg',
                              props: {
                                  windowEnum: "Edit",
                              }
                          });
                      
                          sf.ui.proTools.clipConsolidate();
                      
                          sf.ui.proTools.waitForNoModals();
                      }
                      
                      function main() {
                          //Prompt for Bounce Name and store in variable.
                          const bounceName = prompt('Please enter bounce name.')
                          if (bounceName == "null" || bounceName == null) throw `No name was entered... Bounce has been canceled`;
                      
                          sf.ui.proTools.appActivateMainWindow();
                          
                          sf.ui.proTools.mainWindow.invalidate();
                      
                          //Variables for Instrumental bounce
                          const InstrumentalBounceSettings = {
                              bounceName: bounceName,
                              bounceSuffix: 'Instrumental',
                              trackToMute: 'Vox Master',
                              bounceSource: bounceSource,
                              presetNum: 1,
                              bounceDirectory: 'Bounced Files/',
                          };
                      
                          doBounce(InstrumentalBounceSettings);
                      
                          //Variables for Non Instrumental bounce
                          const sixteenFourtyFourBounceSettings = {
                              bounceName: bounceName,
                              bounceSuffix: '16-44',
                              trackToMute: 'Vox Master',
                              bounceSource: bounceSource,
                              presetNum: 2,
                              bounceDirectory: 'Bounced Files/',
                          };
                      
                          doBounce(sixteenFourtyFourBounceSettings);
                      
                          commitStems();
                      }
                      
                      main();
                      

                      If I find some more time I'll add on the export section, and clean the script up a bit.

                      If you are confused by anything in the script let me know and I'll try to explain it as best as I can.

                      Also if any errors occur let me know. :-)

                      Rock on!
                      K

                  2. In reply toJohn_Costello:

                    The general code needed to wait for a bounce to complete (after having clicked Bounce), is something like this:

                    This copied from actual SF app code:

                            //Start the Bounce, and wait for it to finish!
                            bounceDlg.buttons.whoseTitle.is('Bounce').first.elementClick();
                            sf.wait({ intervalMs: 2000 });
                            sf.ui.proTools.waitForNoModals();
                    

                    The manual wait time of 2 seconds here is designed to ensure that Pro Tools has enough time to make the progress bar visible. After having clicked bounce, there may be a slight delay between the bounce dialog closing, before the progress bar window comes up. This large manual delay ensures we wait at least 2 seconds to allow the progress bar to come up.
                    The last line then waits for that to close.

                    1. John Costello @John_Costello
                        2020-11-24 19:47:04.416Z

                        Thank you so much for this script, Christian! I'm sure this will help me very much!

                      • In reply toJohn_Costello:
                        John Costello @John_Costello
                          2020-11-24 19:42:22.346Z

                          Wow! Your script is truly amazing Kitch!!! Check out this video on my Box account of what we have so far!

                          https://jc3publishingllc.box.com/s/mkk72aj0llynbubngmvdt50bx47zb599

                          I LOVE how it asks me for the name!!!!!!! Soooo slick!

                          The first bounce of the "Full Mix" part isn't functioning yet... not sure why.

                          The Instrumental Mix works once I press enter. (I'm pressing enter in the video to start the instrumental bounce.) The script just needs to unmute the Vocal Master before the 16-44 bounce:

                          sf.ui.proTools.trackGetByName({ name: "Vox Master", makeVisible: true }).track.trackSetMute({
                              targetValue: "Disable",
                          });
                          

                          The 16-44 bounce works excellently! (If the Vocal Master is un-muted.)

                          The Commit tracks part is fantastic! All it needs is the export part:

                          Here is some terrible code that exports the files at the end of the commit part. I couldn't make the "Export Clips as Files" work correctly because that command is actually in a sub menu in the "Clips" window... So for now I did the unforgivable key command. I also tried to integrate the amazing Kitch "Go to the bounce folder" script in the current session as the destination for the export but ugh...

                          sf.keyboard.press({
                              keys: "cmd+shift+k",
                          });
                          
                          sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Choose...').first.elementClick();
                          
                          /* sf.soundflow.runCommand({
                              commandId: 'user:ckfhimahc000g8n100ey7v88x:ckdtpnmso000ljw10ookrerxd',
                              props: {
                                  folder: "Bounce Files",
                              }
                          }); */
                          
                          sf.ui.proTools.windows.whoseTitle.is('Open').first.getElement('AXDefaultButton').elementClick();
                          
                          sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Export...').first.elementClick();
                          

                          I'll keep trying! This Thanksgiving I am the most thankful for my friends here at SoundFlow!

                          1. Kitch Membery @Kitch2020-11-24 21:43:04.007Z

                            Nice!,

                            Ahhh I see.. your first bounce is the full mix... The code you originally provided did not activate a bounce... I'll add that in.

                            The target value of the mute change should be a simple fix.

                            Where is it exactly that you have to press "Enter" to start the bounce? ie What window are you in and what button is "Enter" activating?

                            1. John Costello @John_Costello
                                2020-11-24 22:10:32.984Z

                                YAY!!!!!!!

                                Here is a video of where the script stops for me.

                                Screen Recording 2020-11-24 at 3.08.06 PM.mov (3.51 MiB)

                                1. Kitch Membery @Kitch2020-11-24 22:15:32.564Z2020-11-24 22:47:17.950Z

                                  Great,

                                  Also do you usually have the Clips list open?

                                  Also can you take a screen shot of the "Export Selected" window with the settings you want?

                                  1. John Costello @John_Costello
                                      2020-11-24 23:00:34.697Z

                                      Clips window for me is always closed. I had it open to show where the Export Clips as File command resides.

                                      Heres a shot of the Export dialog box.

                                      The pesky things about the Export Selected box are:

                                      1. The Choose Destination Directory always defaults to the last used location, but I would like it to be the current session bounce files folder.

                                      2. There must be some scripts that hide audio clips in the clips folder that are unknown to me. Sometimes the clips are visible in the clips window and sometimes not. Maybe our script could show all audio clips in the clips window before the commit part?

                                      1. Kitch Membery @Kitch2020-11-24 23:50:49.484Z2020-11-25 00:35:07.504Z

                                        @John_Costello,

                                        Try this;

                                        //Bounce Variables
                                        const bounceDirectory = 'Bounced Files/';
                                        const bounceSource = 'MacBook Pro Speakers 1-2(Stereo)';
                                        
                                        //For sending text message;
                                        const recipientPhoneNumber = '9999999999';
                                        const senderIcloudEmail = 'test@test.com';
                                        const messageText = 'Your Epic bounce script has finished. Time to get back to the studio.';
                                        
                                        const bounceWin = sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first;
                                        
                                        function maximiseBounceWindow() {
                                            const bounceWin = sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first;
                                        
                                            const audioPanel = bounceWin.groups.whoseTitle.is('Audio').first;
                                        
                                            function openAudioPanel() {
                                                if (audioPanel.buttons.whoseTitle.is('Collapser').exists) {
                                                    audioPanel.buttons.whoseTitle.is('Collapser').first.elementClick();
                                                }
                                            }
                                            const locationPanel = bounceWin.groups.whoseTitle.is('Location').first;
                                        
                                            function openLocationPanel() {
                                                if (locationPanel.buttons.whoseTitle.is('Collapser').exists) {
                                                    locationPanel.buttons.whoseTitle.is('Collapser').first.elementClick();
                                                }
                                            }
                                        
                                            switch (bounceWin.frame.h) {
                                                case 268:
                                                    openAudioPanel();
                                                    openLocationPanel();
                                                    break;
                                                case 406:
                                                    openLocationPanel();
                                                    break;
                                                case 393:
                                                    openAudioPanel();
                                                    break;
                                            }
                                        }
                                        
                                        function doBounce(bounceSettings) {
                                            const { bounceName, bounceSuffix, trackToMute, trackMuteTarget, bounceSource, presetNum, bounceDirectory,
                                         } = bounceSettings;
                                        
                                            sf.ui.proTools.trackGetByName({
                                                name: trackToMute,
                                                makeVisible: true
                                            }).track.trackSetMute({
                                                targetValue: trackMuteTarget,
                                            });
                                        
                                            sf.ui.proTools.menuClick({ menuPath: ["File", "Bounce Mix..."], });
                                        
                                            bounceWin.elementWaitFor();
                                        
                                            maximiseBounceWindow();
                                        
                                            bounceWin.buttons.whoseTitle.is('Preset Toggle').allItems[presetNum - 1].elementClick();
                                        
                                            bounceWin.textFields.first.elementSetTextFieldWithAreaValue({
                                                value: bounceName + ' - ' + bounceSuffix,
                                            });
                                        
                                            const locationPanel = bounceWin.groups.whoseTitle.is('Location').first;
                                        
                                            if (locationPanel.textFields.first.value.invalidate().value !== bounceDirectory) {
                                                locationPanel.textFields.first.elementSetTextFieldWithAreaValue({ value: bounceDirectory });
                                            }
                                        
                                            bounceWin.buttons.whoseTitle.is('Bounce').first.elementClick();
                                        
                                        
                                            const mp3Window = sf.ui.proTools.windows.whoseTitle.is('MP3').first;
                                        
                                            mp3Window.elementWaitFor({
                                                waitType: 'Appear',
                                                pollingInterval: 10,
                                                timeout: 100,
                                                onError: 'Continue'
                                            });
                                        
                                            if (mp3Window.buttons.whoseTitle.is('OK').first.exists) {
                                                mp3Window.buttons.whoseTitle.is('OK').first.elementClick();
                                        
                                                mp3Window.elementWaitFor({ waitType: 'Disappear' })
                                            };
                                        
                                            bounceWin.elementWaitFor({ waitType: 'Disappear' })
                                        
                                            sf.ui.proTools.waitForNoModals();
                                        }
                                        
                                        function exportClips() {
                                            sf.ui.proTools.mainWindow.invalidate();
                                        
                                            const sessionDirectory = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/').slice(1);
                                        
                                            sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Clip List').first.popupMenuSelect({
                                                menuPath: ["Clear Find"],
                                            });
                                        
                                            try {
                                                sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Clip List').first.popupMenuSelect({
                                                    menuPath: ["Expor Clips as Files..."],
                                                });
                                            } catch (err) {
                                                sf.keyboard.press({
                                                    keys: "cmd+shift+k",
                                                });
                                            }
                                        
                                            const win = sf.ui.proTools.windows.whoseTitle.is('Export Selected').first;
                                        
                                            win.elementWaitFor();
                                        
                                            const popupButtons = win.children.filter(button => button.fullRole == "AXPopUpButton");
                                        
                                            const sampleRate = popupButtons[0];
                                            const bitDepth = popupButtons[1];
                                            const fileFormat = popupButtons[2];
                                            const fileTypeBtn = popupButtons[3];
                                        
                                            if (fileTypeBtn.value.value != 'WAV')
                                                fileTypeBtn.popupMenuSelect({ menuPath: ['WAV'] });
                                        
                                            if (fileFormat.value.value != 'Interleaved')
                                                fileFormat.popupMenuSelect({ menuPath: ['Interleaved'] });
                                        
                                            if (bitDepth.value.value != '24 Bit')
                                                bitDepth.popupMenuSelect({ menuPath: ['24 Bit'] });
                                        
                                            if (sampleRate.value.value != '48 kHz')
                                                sampleRate.popupMenuSelect({ menuPath: ['48 kHz'] });
                                        
                                            win.buttons.whoseTitle.is('Choose...').first.elementClick();
                                        
                                            const openDlg = sf.ui.proTools.windows.whoseTitle.is('Open').first;
                                            const sheet = openDlg.sheets.first;
                                        
                                            openDlg.elementWaitFor();
                                        
                                            sf.keyboard.type({ text: '/' });
                                        
                                            sf.keyboard.type({ text: sessionDirectory + '/Bounced Files' });
                                        
                                            sf.wait({ intervalMs: 500 });
                                        
                                            sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"');
                                        
                                            sf.ui.proTools.windows.whoseTitle.is('Open').first.getElement('AXDefaultButton').elementClick();
                                        
                                            win.buttons.whoseTitle.is('Export...').first.elementClick();
                                        
                                            win.elementWaitFor({ waitType: 'Disappear' });
                                        
                                            sf.ui.proTools.waitForNoModals();
                                        }
                                        
                                        function sendTextMessage() {
                                            sf.system.execAppleScript({
                                                script: `
                                                tell application "Messages"
                                                    send "${messageText}" to buddy "${recipientPhoneNumber}" of service "E:${senderIcloudEmail}"
                                                end tell`
                                            });
                                        }
                                        
                                        function commitStems() {
                                            sf.soundflow.runCommand({
                                                commandId: 'user:ckfldmfi900002p10aqtdyo1z:ckfjjq34x00030y103bt2x0cg',
                                                props: {
                                                    commitOrFreeze: "Commit",
                                                    insertChoice: "J",
                                                    commitRoutingFolders: true,
                                                    multipleTracksProcessMode: "As a Group",
                                                    commitTarget: "Edit Selection",
                                                    commitAction: "Do Nothing",
                                                    commitConsolidateClips: false,
                                                    commitOffline: false,
                                                }
                                            });
                                        
                                            sf.soundflow.runCommand({
                                                commandId: 'user:ckfhimahc000g8n100ey7v88x:ckdv1td13000dyq10taeszpsg',
                                                props: {
                                                    windowEnum: "Edit",
                                                }
                                            });
                                        
                                            sf.ui.proTools.clipConsolidate();
                                        
                                            sf.ui.proTools.waitForNoModals();
                                        }
                                        
                                        function main() {
                                            const sessionDirectory = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/').slice(1);
                                        
                                            //Prompt for Bounce Name and store in variable.
                                            const bounceName = prompt('Please enter bounce name.')
                                            if (bounceName == "null" || bounceName == null) throw `No name was entered... Bounce has been canceled`;
                                        
                                            sf.ui.proTools.appActivateMainWindow();
                                        
                                            sf.ui.proTools.mainWindow.invalidate();
                                        
                                            //Variables for Full Mix bounce
                                            const fullMixBounceSettings = {
                                                bounceName: bounceName,
                                                bounceSuffix: 'Full Mix',
                                                trackToMute: 'Vox Master',
                                                trackMuteTarget: 'Disable',
                                                bounceSource: bounceSource,
                                                presetNum: 1,
                                                bounceDirectory: 'Bounced Files/',
                                            };
                                        
                                            doBounce(fullMixBounceSettings);
                                        
                                            //Variables for Instrumental bounce
                                            const InstrumentalBounceSettings = {
                                                bounceName: bounceName,
                                                bounceSuffix: 'Instrumental',
                                                trackToMute: 'Vox Master',
                                                trackMuteTarget: 'Enable',
                                                bounceSource: bounceSource,
                                                presetNum: 1,
                                                bounceDirectory: 'Bounced Files/',
                                            };
                                        
                                            doBounce(InstrumentalBounceSettings);
                                        
                                            //Variables for Non Instrumental bounce
                                            const sixteenFourtyFourBounceSettings = {
                                                bounceName: bounceName,
                                                bounceSuffix: '16-44',
                                                trackToMute: 'Vox Master',
                                                trackMuteTarget: 'Disable',
                                                bounceSource: bounceSource,
                                                presetNum: 2,
                                                bounceDirectory: 'Bounced Files/',
                                            };
                                        
                                            doBounce(sixteenFourtyFourBounceSettings);
                                        
                                            commitStems();
                                        
                                            exportClips();
                                        
                                            sf.directory.open({ path: sessionDirectory + '/Bounced Files' })
                                        
                                            sendTextMessage();
                                        }
                                        
                                        main();
                                        

                                        UPDATED

                                        1. Kitch Membery @Kitch2020-11-24 23:52:48.631Z

                                          @John_Costello,

                                          And again be sure to update the info at the top so it sends you the message etc.

                                          Rock on

                                          1. John Costello @John_Costello
                                              2020-11-25 00:26:01.646Z

                                              So close!!!!!! It stops just after the first bounce completes. I love how the words Full Mix get appended to the file name!

                                              1. Kitch Membery @Kitch2020-11-25 00:27:18.387Z

                                                What's the error message say?

                                                1. John Costello @John_Costello
                                                    2020-11-25 00:28:58.521Z

                                                    24.11.2020 17:23:22.29 [Backend]: Logging unknown error in action (02) GetTrackByNameAction: Parent's UIElement was null:

                                                    24.11.2020 17:23:22.29 [Backend]: !! Command Error: Bounce All Masters [user:ckbh254mu00003t10obrbnu93:ckhwa2pau000018105rimfcxc]:
                                                    Parent's UIElement was null: (Bounce All Masters: Line 50)
                                                    System.Exception: Parent's UIElement was null:
                                                    at SoundFlow.Shortcuts.Ax.AxNodes.AxNode.RequireParentUI() + 0x82
                                                    at SoundFlow.Shortcuts.Ax.AxNodes.AxList1.CreateList() + 0x42 at SoundFlow.Shortcuts.Ax.AxNodes.AxNode.GetOrCreateValue[TValue](TValue&, Func1) + 0x24
                                                    at SoundFlow.Shortcuts.Automation.Actions.GetTrackByNameAction.d__9.MoveNext() + 0x5e
                                                    --- End of stack trace from previous location where exception was thrown ---
                                                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
                                                    at sfbackend!+0x178b40b
                                                    at sfbackend!+0x178b346
                                                    at SoundFlow.Shortcuts.Automation.AutoAction`1.d__20.MoveNext() + 0x317

                                                    << Command: Bounce All Masters [user:ckbh254mu00003t10obrbnu93:ckhwa2pau000018105rimfcxc]

                                                    1. John Costello @John_Costello
                                                        2020-11-25 00:29:11.067Z

                                                        Is this the info?

                                                        1. John Costello @John_Costello
                                                            2020-11-25 00:29:53.410Z

                                                            There was also the error that flashed on the screen for a very brief moment. Is that a different one?

                                                            1. Kitch Membery @Kitch2020-11-25 00:34:39.185Z

                                                              I've updated it give it a go now. :-)

                                                              1. John Costello @John_Costello
                                                                  2020-11-25 00:50:12.002Z

                                                                  Amazing!!!!!!!

                                                                  All is incredibly cool except just after the commit, we get:

                                                                  24.11.2020 17:47:10.16 [Backend]: !! Command Error: Bounce All Masters [user:ckbh254mu00003t10obrbnu93:ckhwa2pau000018105rimfcxc]:
                                                                  Could not open popup menu (Bounce All Masters: Line 101)
                                                                  popupMenu.open.fromElement requires an element

                                                                  Luv luv luv!!!!!

                                                                  1. Kitch Membery @Kitch2020-11-25 00:51:58.043Z

                                                                    Is your clips list open?

                                                                    1. Kitch Membery @Kitch2020-11-25 00:52:39.236Z

                                                                      Heading out for a walk, but will be back in 45. :-)

                                                                      1. In reply toKitch:
                                                                        John Costello @John_Costello
                                                                          2020-11-25 00:52:45.971Z

                                                                          Clips list is closed. Does it need to be open?

                                                                          1. Kitch Membery @Kitch2020-11-25 00:53:26.886Z

                                                                            Yes.

                                                                            1. GGabriel Lundh @Gabriel_Lundh
                                                                                2020-11-25 11:05:03.713Z2020-11-25 11:15:46.093Z

                                                                                Hi @Kitch and John!
                                                                                Absolutley love what you've done here!
                                                                                I tried to hijack just the message part of this script and all its constants to make it work as a standalone script. That way it could be inserted in other scripts (love this function)!!
                                                                                I seem to get it to run, but I get no prompt to allow SF to sound the message - so no Message gets sent?

                                                                                //For sending text message;
                                                                                const recipientPhoneNumber = '999999999';
                                                                                const senderIcloudEmail = 'name.name@icloud.com';
                                                                                const messageText = 'Your Epic bounce script has finished. Time to get back to the studio.';
                                                                                
                                                                                
                                                                                function sendTextMessage() {
                                                                                    sf.system.execAppleScript({
                                                                                        script: `
                                                                                        tell application "Meddelanden"
                                                                                            send "${messageText}" to buddy "${recipientPhoneNumber}" of service "E:${senderIcloudEmail}"
                                                                                        end tell`
                                                                                    });
                                                                                }
                                                                                sendTextMessage();
                                                                                
                                                                                

                                                                                I have removed the number and email here - but its correct in my script!
                                                                                Thank you so much!!

                                                                                1. Kitch Membery @Kitch2020-11-25 21:57:16.476Z

                                                                                  Hi @Gabriel_Lundh,

                                                                                  Yeah its a super handy script.

                                                                                  Is seems you have changed the tell application line to read tell application "Meddelanden" this needs to be changed back to tell application "Messages". Unless "Meddelanden" is the name of the mac messages program on your Mac. (Are you in Sweeden?)

                                                                                  Then all you need to do is set the recipientPhoneNumber, senderIcloudEmail & messageText to reflect the correct information.

                                                                                  Note that the iCloud email address must match your iCloud email that can be found by opening your Mac OS "System Preferences", from the apple menu and selecting "Apple ID" (or iCloud for older Mac OS). The email adress will be located under your user icon.

                                                                                  You will need to run it once and allow the system permission to send texts.

                                                                                  Let me know if that works.! :-)

                                                                                  1. GGabriel Lundh @Gabriel_Lundh
                                                                                      2020-11-26 11:47:44.328Z

                                                                                      Hi Kitch!

                                                                                      I tried the "Meddelanden" as well when the script did not work as it is the name of the app in my Swedish system - But now when I switched back and put in the phone number in a format excatly as specified under the Apple ID it WORKS!
                                                                                      The only problem now is that I get no notification on my phone as the message app on the computer marks it as "read" hence, not notifying on the phone. Have you managed a way around this?

                                                                                      Thanks as always for your help Kitch!

                                                                                      1. GGabriel Lundh @Gabriel_Lundh
                                                                                          2020-11-26 13:53:13.155Z

                                                                                          Or is there a similar command for emailing instead? Maybe that would work better to get around the notification problem?
                                                                                          Thank you!

                                                                                          1. Kitch Membery @Kitch2020-11-27 07:52:49.192Z

                                                                                            Hi Gabriel,

                                                                                            I wish I could help you with this one but I'm not sure how to fix that.

                                                                                            1. GGabriel Lundh @Gabriel_Lundh
                                                                                                2020-11-27 10:56:47.142Z

                                                                                                Hi Kitch!
                                                                                                Thank you for your reply, its just a minor detail - I'm so glad that the SMS scripts is working!!

                                                                                                Hope you get a great day!

                                                                                                1. Kitch Membery @Kitch2020-11-27 22:45:12.540Z

                                                                                                  You too Gabriel! :-)

                                                                                          2. In reply toKitch:
                                                                                            AAlex Oldroyd @Alex_Oldroyd8
                                                                                              2022-06-19 18:01:38.776Z

                                                                                              Hi @Kitch. I can't get the messages script to run at all unfortunately. I've never used apple scripts before - could it be an issue with that?

                                                                                              Thanks

                                                                                              Alex

                                                                                              1. Kitch Membery @Kitch2022-06-21 22:03:21.513Z

                                                                                                Hi Alex,

                                                                                                I'm not sure... Are you seeing any errors?

                                                                                                I'd suggest checking out this thread Notifications in Soundflow vs system notifications #post-4

                                                                                                If the scripts in that thread fail give this script a go;

                                                                                                /**
                                                                                                 * @param {object} obj
                                                                                                 * @param {string} obj.messageText
                                                                                                 * @param {string} obj.recipientPhoneNumber
                                                                                                 */
                                                                                                function sendTextMessage({ messageText, recipientPhoneNumber }) {
                                                                                                    sf.system.execAppleScript({
                                                                                                        script: `
                                                                                                        set targetMessage to "${messageText}"
                                                                                                        tell application "Messages"
                                                                                                            set targetService to 1st service whose service type = iMessage
                                                                                                            set targetBuddy to buddy "${recipientPhoneNumber}" of targetService
                                                                                                            send targetMessage to targetBuddy
                                                                                                        end tell`
                                                                                                    });
                                                                                                }
                                                                                                
                                                                                                sendTextMessage({
                                                                                                    messageText: "This is a message from SoundFlow", // Add your message here.
                                                                                                    recipientPhoneNumber: "+18189999999", // Add your phone number here.
                                                                                                });
                                                                                                

                                                                                                Rock on!

                                                                                                1. AAlex Oldroyd @Alex_Oldroyd8
                                                                                                    2022-06-22 11:21:18.997Z

                                                                                                    That works perfectly, @Kitch !! Thank you!

                                                                                          3. In reply toJohn_Costello:
                                                                                            Kitch Membery @Kitch2020-11-25 00:53:44.338Z

                                                                                            I'll update it later to open and close it.

                                                                                            1. John Costello @John_Costello
                                                                                                2020-11-25 01:08:18.361Z

                                                                                                You are so amazing!!!!!!!!!!! I am completely astounded!!!!! It went through the whole series of bounces and made the stems in the perfect folder!!!!!!!

                                                                                                I did see SoundFlow ask for messages permissions but not really message anything. That is not crucial to your success!

                                                                                                Tonight we dance in the streets and shout KITCH!!! KITCH!!!! KITCH!!!! over and over until we fall down drunk!!!!!

                                                                                                YOU Rock on!!!!!!

                                                                                                1. Kitch Membery @Kitch2020-11-25 01:45:07.632Z

                                                                                                  Hahahaha This is my favorite forum post ever!!! You are welcome mate! :-)

                                                                                                  Yes you will need to give the system permission to send a message from the email address attached to your iCloud. But just once.

                                                                                                  Be sure to do a full screen capture of the script and post it on the SoundFlow facebook page. The SoundFlow community love this stuff!

                                                              2. In reply toJohn_Costello:
                                                                John Costello @John_Costello
                                                                  2020-11-25 01:37:45.446Z

                                                                  Yay yay yay!!!!!!

                                                                  So I pasted in a couple more lines of terrible code to accomplish undoing the consolidate audio and also undoing the commit. This saves me the drive space of having the stems in the session as well as in the bounce folder.

                                                                  Then I pasted in some other terrible code that does the messaging.

                                                                  Here is a video of the whole enchilada!!!!! (I'm ok with my data being displayed here for the moment.)

                                                                  https://jc3publishingllc.box.com/s/lba5heggot6p7hjff63atgno67ozetl5

                                                                  Thank you so much again! A miracle for me!

                                                                  1. In reply toJohn_Costello:
                                                                    John Costello @John_Costello
                                                                      2020-11-30 17:05:55.718Z

                                                                      Heya Kitch! I hope you had a nice holiday! I've been using our big script for a few days on large mixes and am having difficulty with the last part of the script, when it makes the stems. I believe when I'm bouncing down big sessions there isn't quite enough wait time befor the stem commands. I have been studying this script very hard but can't find out where to lengthen the wait times. The first 3 bounces are extremely cool, but sometimes the presets get reset, and the script gets stuck at 16-44. In the future as I get better maybe there would be.a way to add something at the beginning that checks to make sure everything is set up properly? Anyway here are the errors, I looked very close and I just can't make heads or tails exactly what they mean, besides I think there needs to be some more wait time.

                                                                      25.11.2020 14:40:42.05 [Backend]: !! Command Error: Bounce All Masters-2 [user:ckbh254mu00003t10obrbnu93:ckhwps9yj0001zl10bm4qf3n2]:
                                                                      Error running command package:ckhwa2pau000018105rimfcxc (Bounce All Masters-2: Line 1)
                                                                      Error: Commit or Freeze up to Selected Insert: Line 94
                                                                      (Bounce All Masters line 172)

                                                                      25.11.2020 16:03:50.00 [Backend]: Logging unknown error in action (02) RunCommandAction: Bounce All Masters: Line 101
                                                                      !! Command Error: Bounce All Masters-2 [user:ckbh254mu00003t10obrbnu93:ckhwps9yj0001zl10bm4qf3n2]:
                                                                      Error running command package:ckhwa2pau000018105rimfcxc (Bounce All Masters-2: Line 1)
                                                                      Could not open popup menu (Bounce All Masters: Line 101)
                                                                      Popup menu was not found
                                                                      Popup window was not found after waiting 2000 ms

                                                                      << Command: Bounce All Masters-2 [user:ckbh254mu00003t10obrbnu93:ckhwps9yj0001zl10bm4qf3n2]

                                                                      25.11.2020 16:35:24.20 [Backend]: Logging error in action (01) WaitForPopupMenuAction: Popup window was not found after waiting 2000 ms
                                                                      Logging error in action (01) OpenPopupMenuFromElementAction: Popup menu was not found
                                                                      Logging error in action (01) PopupMenuSelectAction: Could not open popup menu

                                                                      25.11.2020 16:35:24.20 [Backend]: Logging unknown error in action (02) RunCommandAction: Bounce All Masters: Line 101

                                                                      25.11.2020 16:35:24.20 [Backend]: !! Command Error: Bounce All Masters-2 [user:ckbh254mu00003t10obrbnu93:ckhwps9yj0001zl10bm4qf3n2]:
                                                                      Error running command package:ckhwa2pau000018105rimfcxc (Bounce All Masters-2: Line 1)
                                                                      Could not open popup menu (Bounce All Masters: Line 101)
                                                                      Popup menu was not found
                                                                      Popup window was not found after waiting 2000 ms

                                                                      28.11.2020 11:47:24.57 [Backend]: !! Command Error: Bounce All Masters-2 [user:ckbh254mu00003t10obrbnu93:ckhwps9yj0001zl10bm4qf3n2]:
                                                                      Error running command package:ckhwa2pau000018105rimfcxc (Bounce All Masters-2: Line 1)
                                                                      Error: Commit or Freeze up to Selected Insert: Line 94
                                                                      (Bounce All Masters line 172)

                                                                      << Command: Bounce All Masters-2 [user:ckbh254mu00003t10obrbnu93:ckhwps9yj0001zl10bm4qf3n2]

                                                                      Thank you all for the amazing help!

                                                                      1. Kitch Membery @Kitch2020-12-23 10:18:40.233Z

                                                                        Totally missed this @John_Costello, I'll check it out when I get a chance. What version of Pro Tools are you on btw?

                                                                        1. John Costello @John_Costello
                                                                            2020-12-23 17:19:49.703Z

                                                                            Hi Kitch!!!!

                                                                            No worries! I so do appreciate your help! PT 2020.12. (Latest.) The majority of the script runs fine. It's totally on me to learn more about coding in SoundFlow.

                                                                            Thank you so much!
                                                                            JC3