No internet connection
  1. Home
  2. How to

How could I create a macro that only runs when I'm renaming tracks in Pro Tools?

By Bobby Knepper @Bobby_Knepper
    2023-12-06 19:02:47.866Z

    Essentially I want to create simple macros to jump to the next track or last track when I'm renaming a lot of tracks at once. Cmd + arrow is a bit clunky for me, I'd rather use Tab and shift + tab. I have the simple code written, but cannot figure out how to ensure it will only run when I am currently renaming tracks (not batch renaming, by the way). Want to save tab to transient as it is a great feature.

    sf.keyboard.press({
    keys: "cmd+right",
    fast: true,
    });

    Solved in post #2, click to view
    • 2 replies
    1. Chad Wahlbrink @Chad2023-12-06 20:19:35.361Z

      Hey @Bobby_Knepper !

      Currently, keyboard commands for a macro can only be limited by a focused application (only run when Pro Tools is focused, only run when Finder is focused, etc).

      Therefore, I would approach this by running a short script that checks for the track name dialog window, and will either click "Next" or "Previous" if that dialog is present, or press the intended keyboard shortcut ("tab" or "shift+tab" in this instance).

      Here are the two scripts I would set up with keyboard triggers (one for "tab" / "next" and one for "shift+tab" / "previous").

      Script for Moving to Next Track with Tab

      
      // This script will click "Next" on the track naming dialog if the dialog window is present, otherwise, it performs "Tab"
      // This script is meant to be setup with a Keyboard Trigger of Tab when Pro Tools is focused
      
      let nameTrackDialogisOpen = sf.ui.proTools.windows.first.children.whoseRole.is("AXStaticText").whoseValue.is("Name the track:").first.exists
      
      if (nameTrackDialogisOpen) {
          sf.ui.proTools.windows.first.buttons.whoseTitle.is("Next").first.elementClick();
      } else {
          sf.keyboard.press({
              keys: 'tab'
          });
      }
      

      Script for Moving to Previous Track with Shift+Tab

      
      // This script will click "Previous" on the track naming dialog if the dialog window is present, otherwise, it performs "Shift+Tab"
      // This script is meant to be setup with a Keyboard Trigger of Shift+Tab when Pro Tools is focused
      
      let nameTrackDialogisOpen = sf.ui.proTools.windows.first.children.whoseRole.is("AXStaticText").whoseValue.is("Name the track:").first.exists
      
      if (nameTrackDialogisOpen) {
          sf.ui.proTools.windows.first.buttons.whoseTitle.is("Previous").first.elementClick();
      } else {
          sf.keyboard.press({
              keys: "shift+tab",
          });
      }
      

      Also, as a heads up for the future, you can format code on the forum, by wrapping code using three ``` characters. See the guide here:

      https://soundflow.org/docs/forum/formatting-code

      Reply2 LikesSolution
      1. BBobby Knepper @Bobby_Knepper
          2023-12-07 21:10:26.907Z

          Thanks so much man! You're the best!