No internet connection
  1. Home
  2. How to

Select Record mode not working anymore (PT 2023.6)

By Thomas Gloor @Thomas_Gloor
    2023-06-23 18:05:20.364Z

    Hi everyone,

    Since updating to 2023.6, this bit of code doesn't work anymore. Does anybody have an idea how I can circumvent it? It opens the popup menu but doesn't select the value!

    Thank you lots!

    T.

        
    let ptMainWindow = pt.mainWindow
    let recordModeSelector = ptMainWindow.transportViewCluster.groups.whoseTitle.is("Normal Transport Buttons").first
    let recordButton = recordModeSelector.buttons.whoseTitle.is("Record Enable").first
    if (recordButton.value.value !== "Normal") {
            recordButton.popupMenuSelect({ isRightClick: true, menuPath: ["Normal"], targetValue: "Enable", });
        }
    
    • 8 replies
    1. Kitch Membery @Kitch2023-06-23 18:22:21.050Z

      Hi @Thomas_Gloor,

      Try adding a small relative offset to the button. Replace line 6 with the following code.

          recordButton.popupMenuSelect({
              isRightClick: true, menuPath: ["Normal"],
              targetValue: "Enable",
              relativePosition: { x: 5, y: 5 }
          });
      
      1. TThomas Gloor @Thomas_Gloor
          2023-06-23 18:27:46.324Z

          Thank you @Kitch !

          I used this in the meantime. Which one will be more solid according to you? I usually try to avoid clicking if I can. The code I provided is a bit old.

              const menuItems = [
                  { name: 'Destructive Record', isChecked: pt.getMenuItem('Options', 'Destructive Record').isMenuChecked },
                  { name: 'Loop Record', isChecked: pt.getMenuItem('Options', 'Loop Record').isMenuChecked },
                  { name: 'QuickPunch', isChecked: pt.getMenuItem('Options', 'QuickPunch').isMenuChecked },
                  { name: 'TrackPunch', isChecked: pt.getMenuItem('Options', 'TrackPunch').isMenuChecked },
                  { name: 'DestructivePunch', isChecked: pt.getMenuItem('Options', 'DestructivePunch').isMenuChecked }
              ];
          
              menuItems.forEach(item => {
                  if (item.isChecked) {
                      pt.menuClick({ menuPath: ['Options', item.name] });
                  }
              });
          
          
          1. Kitch Membery @Kitch2023-06-23 18:40:03.443Z

            Are you just trying to set the Record mode?

            You should just be able to use the following code, as only one record mode can be set at a time, so there is no need to check the state of each menu item.

            let recordMode = "Loop Record".
            sf.ui.proTools.menuClick({ menuPath: ['Options', recordMode] });
            

            But yes it's better to use menu clicks for this scenario as you don't have to worry about the Transport being visible and there is no visible automation being done when using the menu click.

            1. TThomas Gloor @Thomas_Gloor
                2023-06-24 07:37:17.121Z

                Hi Kitch.
                Actually I’m trying to setup the record mode to “Normal”, so I need to un-check all other modes. I used to do it by right-clicking the Record button, but that problem
                Showed up.

                1. Kitch Membery @Kitch2023-06-24 07:59:02.839Z

                  Ahh yes I did not see it worked that way.

                  There is a handy new method in the Pro Tools API that will work in PT 2023.6 for setting the record mode. Here it is.

                  sf.app.proTools.setRecordMode({ recordMode: "Normal" });
                  
                  1. In reply toThomas_Gloor:
                    Kitch Membery @Kitch2023-06-24 08:01:17.165Z

                    There other options are in there also. Place your cursor in between the quotation marks and then use Control + Spacebar" to show the options.

                    1. In reply toThomas_Gloor:
                      Kitch Membery @Kitch2023-06-24 08:12:04.728Z

                      Or, to do it without the Pro Tools API for older PT versions.

                      /**
                       * @param {Object} obj
                       * @param {'Normal'|'Destructive Record'|'Loop Record'|'QuickPunch'|'TrackPunch'|'DestructivePunch'} obj.mode
                       */
                      function setRecordMode({ mode }) {
                          const menuItems = [
                              'Destructive Record',
                              'Loop Record',
                              'QuickPunch',
                              'TrackPunch',
                              'DestructivePunch'
                          ];
                      
                          if (mode === "Normal") {
                              menuItems.forEach(item => {
                                  sf.ui.proTools.menuClick({
                                      menuPath: ['Options', item],
                                      targetValue:"Disable"
                                  })
                              });
                          } else {
                              sf.ui.proTools.menuClick({
                                  menuPath: ['Options', mode],
                              });
                          }
                      }
                      
                      setRecordMode({ mode: "Normal" });
                      
                      1. TThomas Gloor @Thomas_Gloor
                          2023-06-26 11:15:45.842Z

                          Hey @Kitch ,

                          I took the liberty of adding a "Continue on error", so it works on both PT Ultimate and PT Studio (As all the record modes aren't present.

                          //////////////////////////////////////////////////SET RECORD MODE
                          /** @param {Object} obj @param {'Normal'|'Destructive Record'|'Loop Record'|'QuickPunch'|'TrackPunch'|'DestructivePunch'} obj.mode */
                          function setRecordMode({ mode }) {
                              let menuItems = [
                                  'Destructive Record',
                                  'Loop Record',
                                  'QuickPunch',
                                  'TrackPunch',
                                  'DestructivePunch'
                              ];
                          
                              if (mode === "Normal") {
                                  menuItems.forEach(item => {
                                      pt.menuClick({
                                          menuPath: ['Options', item],
                                          onError: "Continue",
                                          targetValue: "Disable"
                                      })
                                  });
                              } else {
                                  pt.menuClick({
                                      menuPath: ['Options', mode],
                                  });
                              }
                          }