No internet connection
  1. Home
  2. How to

Creat markers and name them in PT

By marcello azevedo @marcello_azevedo
    2021-03-10 18:57:10.871Z

    This sounds very easy but yet I can't get it to work.
    I need to create a marker at parked timeline and name it in one shot.
    I'm trying to create a deck with all my usual markers to breeze through the process while setting up a session.
    I've tried keyboard input "Numpad ENTER" and than text input (whatever name I want ) no go
    Any help is much appreciated, thanks

    • 20 replies

    There are 20 replies. Estimated reading time: 18 minutes

    1. Chris Shaw @Chris_Shaw2021-03-10 19:29:17.326Z2021-03-11 02:20:19.561Z

      This script will do what you want. It will let you specify a number for the marker too. If you need to use your own number just change the second line var markerNumber = "" to something like var markerNumber = "46".
      To name your marker just change "Test Marker" in the third line to whatever name you want.

      sf.ui.proTools.appActivateMainWindow();
      
      // set constants and variables
      var markerName = "Test Marker";
      var markerNumber = ""
      
      const memLocationDialog = sf.ui.proTools.newMemoryLocationDialog;
      
      
      // Open Memory Location Dialog
      sf.keyboard.press({
          keys: "numpad enter",
      });
      memLocationDialog.elementWaitFor();
      
      //  Enter Memory location name
      memLocationDialog.textFields.whoseTitle.is("").allItems[1].elementSetTextFieldWithAreaValue({
          value: markerName,
      });
      
      // Enter Marker number
      if (markerNumber != "") {
          memLocationDialog.textFields.whoseTitle.is("").allItems[2].elementSetTextFieldWithAreaValue({
              value: markerNumber,
              useMouseKeyboard: true
          });
      }
      
      // Close memory location window
      memLocationDialog.buttons.whoseTitle.is("OK").first.elementClick();
      
      1. marcello azevedo @marcello_azevedo
          2021-03-11 04:05:49.684Z

          Thank you so much Chris!!!
          It worked perfectly

          1. BTW - Instead of copying the script multiple times for each variation of the script you need (different names, numbers etc) you can take advantage of SoundFlow templates.
            There isn't an official tutorial for it yet (Kitch has it on his to do list) but Christian did a brief walkthrough on it when the feature was announced on facebook.
            He starts @ 2:44
            https://www.facebook.com/watch/?v=633065107406660

          2. In reply toChris_Shaw:
            Dav3 @D_av_3
              2021-03-28 18:01:06.170Z

              really interesting..if i need to do the same thing while protools is in play..what should i change in the code?

              1. It will still work when PT is in play.

                1. Dav3 @D_av_3
                    2021-03-28 23:37:47.299Z

                    Hi Chris. Thanks as always for your support.

                    I would like to use this script like this ..
                    Assign 5 scripts to 5 buttons of the streamdeck that insert markers with 5 different predetermined names (e.g. hits, booms, whoosh ..)

                    When I tried the script it assigned the name I had entered (Test Marker in your script) only when protools was in stop ... while when it was in play it entered the default name marker 1..etc ..

                    1. Davide, I think that's happening because you may have the "Auto-Name Memory Locations when Playing" turned on. If you disable it, the script should work. You can find that option in the Pro Tools Preferences, under the Editing tab, to the bottom-left, under the Memory Locations label.

                      1. Dav3 @D_av_3
                          2021-03-30 05:12:16.878Z

                          exactly!
                          ...and now it works perfectly
                          thank you guys!

                2. Jason King @Jason_King
                    2022-07-20 03:31:55.187Z

                    Is there a way to do this without script and also without a pre defined memory location number?
                    I tried the below but I keep getting the error "could not find UI element"

                    1. Jason,
                      The reason you're getting an error is that SF is looking for a a text field in the New Memory locations dialog that contains the text "Location 3".
                      You need to change the value of 'First Text Field "Location 3" ' in the macro action.
                      To do this click 'First Text Field "Location 3" ' and select "2nd Text Field" like this:

                      You'll also have to do a similar thing to your next macro action "Set Value of Text Filed with Text Area".

                      Generally speaking, when you're working with macro actions (UI elements in particular), you should use the more generic descriptions of the UI elements you want to interact with as described above whenever possible.

                      Hope this helps,
                      //CS//

                      1. In reply toChris_Shaw:
                        Jason King @Jason_King
                          2022-07-20 22:16:08.508Z

                          Thanks for the info @Chris_Shaw. I got it to work once then restarted SF. Same thing. Works once and then wont work again. Same error message as before

                          1. Are you triggering this macro from the editor or with a keyboard / Stream Deck trigger?
                            It's best to run trigger macros/scripts while PT is the active application - triggering from the SF editor can be unpredictable at times - especially when the script / macro uses keyboard presses.

                            Your macros do work on my setup when I trigger it while PT is the active/focused app.

                            If you have to run it from the editor I would convert it to a script first and trigger the script instead of the macro.
                            This should do it:

                            
                            sf.ui.proTools.appActivateMainWindow()
                            
                            sf.keyboard.press({
                                keys: "numpad enter",
                            });
                            
                            sf.ui.proTools.newMemoryLocationDialog.elementWaitFor();
                            
                            sf.ui.proTools.newMemoryLocationDialog.textFields.allItems[1].elementSetTextFieldWithAreaValue({
                                value: "MX",
                            });
                            
                            sf.keyboard.press({
                                keys: "numpad enter",
                            });
                            
                            1. Jason King @Jason_King
                                2022-07-21 01:34:25.852Z

                                From a button on the SD.

                                Very strange. Your conversion of the script works but when I convert it. It doesn't.

                                Here is my converted macro to script

                                sf.keyboard.press({
                                    keys: "numpad enter",
                                });
                                
                                sf.ui.proTools.newMemoryLocationDialog.textFields.allItems[1].elementWaitFor({
                                    waitType: "Appear",
                                });
                                
                                /* sf.ui.proTools.newMemoryLocationDialog.textFields.allItems[1].elementClick(); */
                                
                                sf.ui.proTools.newMemoryLocationDialog.textFields.allItems[1].elementSetTextFieldWithAreaValue({
                                    value: "MX",
                                });
                                
                                sf.keyboard.press({
                                    keys: "numpad enter",
                                });
                                
                                

                                This is your conversion

                                sf.ui.proTools.appActivateMainWindow()
                                
                                sf.keyboard.press({
                                    keys: "numpad enter",
                                });
                                
                                sf.ui.proTools.newMemoryLocationDialog.elementWaitFor();
                                
                                sf.ui.proTools.newMemoryLocationDialog.textFields.allItems[1].elementSetTextFieldWithAreaValue({
                                    value: "MX",
                                });
                                
                                sf.keyboard.press({
                                    keys: "numpad enter",
                                });
                                

                                AND your original code? Which works perfectly.

                                sf.ui.proTools.appActivateMainWindow();
                                
                                // set constants and variables
                                var markerName = "Test Marker";
                                var markerNumber = ""
                                
                                const memLocationDialog = sf.ui.proTools.newMemoryLocationDialog;
                                
                                
                                // Open Memory Location Dialog
                                sf.keyboard.press({
                                    keys: "numpad enter",
                                });
                                memLocationDialog.elementWaitFor();
                                
                                //  Enter Memory location name
                                memLocationDialog.textFields.whoseTitle.is("").allItems[1].elementSetTextFieldWithAreaValue({
                                    value: markerName,
                                });
                                
                                // Enter Marker number
                                if (markerNumber != "") {
                                    memLocationDialog.textFields.whoseTitle.is("").allItems[2].elementSetTextFieldWithAreaValue({
                                        value: markerNumber,
                                        useMouseKeyboard: true
                                    });
                                }
                                
                                // Close memory location window
                                memLocationDialog.buttons.whoseTitle.is("OK").first.elementClick();
                                
                                1. Chris Shaw @Chris_Shaw2022-07-21 16:19:03.326Z2022-07-22 01:29:18.597Z

                                  Let's look at the steps in your macro actions -

                                  Step 1: hit enter
                                  Step 2: wait for the second text field in the New Memory Locations Dialog to appear.

                                  The problem with step two is that you're asking SF to search for a text field in a window that hasn't appeared a few microseconds after hitting enter. It's like telling a robot: Order an Uber and immediately open the door to the car and get in - the car hasn't shown up yet.

                                  You should set your second step to wait only for the New Memory Locations Dialog window (after hitting "Pick" click on the New Memory Locations Dialog Window's title bar slightly to the side of the text so that the whole window is highlighted red).

                                  Now that the script has waited for the window to appear there's no need to wait for the text field since it is part of the whole window.

                                  This is why using key commands / presses in SF is discouraged instead of clicking menu items. When clicking menu items SF knows if it needs to wait for a window to appear (or some other action) before proceeding.

                                  In this case there is no menu item for creating a new memory location so when we use a keyboard command / press we have to tell SF specifically what to wait for before proceeding.

                                  1. Jason King @Jason_King
                                      2022-07-21 23:27:43.027Z

                                      Thanks @Chris_Shaw

                                      Thats what I feel like I've done already.

                                      sf.keyboard.press({
                                          keys: "numpad enter",
                                      });
                                      
                                      sf.ui.proTools.newMemoryLocationDialog.textFields.allItems[1].elementWaitFor({
                                          waitType: "Appear",
                                      });
                                      
                                      sf.ui.proTools.newMemoryLocationDialog.textFields.allItems[1].elementSetTextFieldWithAreaValue({
                                          value: "MX",
                                      });
                                      
                                      sf.keyboard.press({
                                          keys: "numpad enter",
                                      });
                                      
                                      1. Actually you haven’t.
                                        That second step should be:
                                        Wait For UI Element: Pro Tools >New Memory Location Dialog”
                                        (without “2nd Text Field”).

                                        1. Jason King @Jason_King
                                            2022-07-22 11:27:54.299Z

                                            Right..... So I literally clicked nowhere in the UI to get it to work.

                                            How does that work???

                            2. marcello azevedo @marcello_azevedo
                                2022-07-20 16:21:12.701Z

                                That's how I'm doing it now, not as sexy as the script but it works great, I created two sets, one to create markers and one to recall the markers and put them on a Deck, I did it for different types of sessions but this one on pict is for regular pop music and it's most common markers.

                                1. O

                                  @Jason_King

                                  @raphaelsepulveda has a great script in his Utilities package called Create/Go To Temp Location it's a template so you can just create as many presets as you want. The first time you press the button it will create a marker with user defined text and every time after when you press it it will take you to that marker.

                                  No coding needed just making presets.

                                  Bests,
                                  Owen

                                  I also have Advanced Memory locations that has some similar functionality but is also packed with a bunch of other bells and whistles. It's honestly a bit more clunky than Raphael's script.

                                  1. T
                                    Thomas Gloor @Thomas_Gloor
                                      2022-07-24 09:02:26.373Z

                                      Hey @marcello_azevedo ,

                                      Here's a little function I wrote that might do what you want. You can modify it to set your marker to do different things.

                                      //////////////////////////////////////////////////CREATE NEW MARKER
                                      function createNewMarker({ newMarkerNumber, newMarkerName }) {
                                          let newMemLocWindow = pt.newMemoryLocationDialog
                                          let cb = newMemLocWindow.checkBoxes
                                          let okBtn = newMemLocWindow.buttons.whoseTitle.is("OK").first
                                          let confDialog = pt.confirmationDialog
                                          let confDialogOK = confDialog.buttons.whoseTitle.is("OK").first
                                          sf.keyboard.press({ keys: "numpad enter", });
                                          newMemLocWindow.elementWaitFor({ waitType: "Appear" });
                                      
                                          if (newMarkerNumber !== undefined) {
                                              sf.wait({ intervalMs: 250 })
                                              pt.newMemoryLocationDialog.textFields.allItems[2].elementClick();
                                              sf.keyboard.press({ keys: "backspace" })
                                              sf.keyboard.type({ text: newMarkerNumber })
                                              sf.keyboard.press({ keys: "tab" })
                                          }
                                      
                                          sf.wait({ intervalMs: 500 })
                                      
                                          if (newMarkerName !== undefined) {
                                              sf.wait({ intervalMs: 250 })
                                              newMemLocWindow.textFields.allItems[1].elementSetTextFieldWithAreaValue({ value: newMarkerNumber + ". " + newMarkerName, });
                                          }
                                      
                                          newMemLocWindow.radioButtons.whoseTitle.is("Marker").first.elementClick();
                                          newMemLocWindow.popupButtons.first.popupMenuSelect({ menuPath: ["Bar | Beat"], });
                                          cb.whoseTitle.is("Zoom Settings").first.checkboxSet({ targetValue: "Disable", });
                                          cb.whoseTitle.is("Pre/Post Roll Times").first.checkboxSet({ targetValue: "Disable", });
                                          cb.whoseTitle.is("Track Visibility").first.checkboxSet({ targetValue: "Disable", });
                                          cb.whoseTitle.is("Track Heights").first.checkboxSet({ targetValue: "Disable", });
                                          cb.whoseTitle.is("Group Enables").first.checkboxSet({ targetValue: "Disable", });
                                          cb.whoseTitle.is("Window Configuration").first.checkboxSet({ targetValue: "Disable", });
                                          okBtn.elementClick();
                                          if (confDialog.exists) { confDialogOK.elementClick(); }
                                          newMemLocWindow.elementWaitFor({ waitType: "Disappear" })
                                      };
                                      

                                      you can call it by writing the following line in your script

                                      createNewMarker({newMarkerNumber: "1", newMarkerName: "MarkerName"});