No internet connection
  1. Home
  2. How to

Entering Program Changes in Pro Tools

By Curtis Macdonald @Curtis_Macdonald
    2023-03-26 03:58:13.890Z

    Hello! I'm trying to automate the process of entering in a specific Program Change in the MIDI Event List, but can't seem to keep the window in focus, or get SF to select the menu path correctly without relying on a keyboard shortcut Cmd+P to insert a PC.

    Below is a little code snippet I'm working with. Here I'm attempting to enter Program Change and CC32 data, each with a value of "24".

    Here I'm testing out a new workflow for using UACC articulations that sends out BOTH Program Change and CC32 information for ease of compatibility across various virtual instruments. Will need to make about a hundred of these commands once set up properly.

    Any help from the SF experts would be hugely appreciated!

    sf.ui.proTools.appActivateMainWindow();
    
        sf.ui.proTools.menuClick({
            menuPath: ["Window", "MIDI Event List"],
            targetValue: "Enable"
        });
    
    sf.keyboard.press({
        keys: "cmd+p",
    });
    
    sf.keyboard.press({
        keys: "right, right, right, numpad 2, numpad 4, right, right, numpad 2, numpad 4, return, 2, 4",
    });
    
    
    
    • 5 replies
    1. Hi Curtis,

      This is very likely something that would require a lot of trial and error to figure out the best way to do it. Simulating keystrokes is always the last resort as I'm sure you know, because it is inherently unstable - as you're seeing, any focus change and the keystrokes would end up in the wrong place.

      I'd try to look into using Set Value of Text Area / Set Value of Text Field with Text Area actions to see if those could help with changing the contents. It's very likely they won't work though, but it's worth a shot.

      Another way to achieve this could be to construct MIDI files and import them instead, but I'm sure that would come with its own drawbacks (and be possibly an order of magnitude more challenging to code).

      1. To focus the window, you'd do something like (written from memory):

        sf.ui.proTools.windows.whoseTitle.is('MIDI Event List').first.elementRaise();
        
        1. You may also be able to learn some techniques from these videos:

      2. Curtis Macdonald @Curtis_Macdonald
          2023-03-26 20:01:09.467Z

          Thank you Christian, I'm unable to select the Midi Events List window via the picker for some reason. SF isn't seeing the entire window, only various elements within. Please see attached. Is this normal? What am I missing?

          link to a gif of the screenshot here: https://www.dropbox.com/s/2xzh9b5uyde6ygu/picker issue.gif?dl=0

          1. I think that's a bug in SF - I noticed something similar recently. For the "Wait for UI Element" it's equally OK to click and select the window's title instead as a workaround.