No internet connection
  1. Home
  2. Support

Keypress command does not properly replicate my keystroke

By DJH @DJH
    2022-02-28 21:36:33.082Z

    Title

    Keypress command does not properly replicate my keystroke

    What do you expect to happen when you run the script/macro?

    Hi - I realize that there is already a system command for making new memory locations (thats what i resorted to after this didn't work), but I'd initally tried "press keys" to create a macro that would create marker #999. This is something I use in my workflow w/ keyboard maestro. I'd like to understand what may be going wrong so I can avoid similar issues in the future....

    To make the macro, I simply tried to simulate the manual keystrokes one would enter: ".0 (enter) (enter)" all on the numeric keypad. It works when i do it manually in pro tools and simulated similarly in KM. But my SF command doesn't work. I noticed that instead of it saying numpad "." /period or decimal, its says "numpad comma". IDK if thats correct or not, but I assumed it should not say comma as I'm not typing a comma when recording the keystrokes. THanks

    Are you seeing an error?

    Not an error exactly, but trying to figure it out and test it yesterday, SF did crash a couple times.

    What happens when you run this script?

    Nothing happens.

    How were you running this script?

    I used a Stream Deck button

    How important is this issue to you?

    3

    Details

    {
        "inputExpected": "Hi - I realize that there is already a system command for making new memory locations (thats what i resorted to after this didn't work), but I'd initally tried \"press keys\" to create a macro that would create marker #999. This is something I use in my workflow w/ keyboard maestro. I'd like to understand what may be going wrong so I can avoid similar issues in the future....\n\nTo make the macro, I simply tried to simulate the manual keystrokes one would enter: \".0 (enter) (enter)\" all on the numeric keypad. It works when i do it manually in pro tools and simulated  similarly in KM. But my SF command doesn't work. I noticed that instead of it saying numpad \".\" /period or decimal, its says \"numpad comma\". IDK if thats correct or not, but I assumed it should not say comma as I'm not typing a comma when recording the keystrokes. THanks",
        "inputIsError": true,
        "inputError": "Not an error exactly, but trying to figure it out and test it yesterday, SF did crash a couple times.",
        "inputWhatHappens": "Nothing happens.",
        "inputHowRun": {
            "key": "-MpfwmPg-2Sb-HxHQAff",
            "title": "I used a Stream Deck button"
        },
        "inputImportance": 3,
        "inputTitle": "Keypress command does not properly replicate my keystroke"
    }

    Source

    //Macro converted to script
    
    
    sf.keyboard.press({
        keys: "numpad comma, numpad 0, numpad enter, numpad enter",
    });
    
    
    

    Links

    User UID: 5oOYQAmkSMeJJ8UYzehWUfmvCyr1

    Feedback Key: sffeedback:5oOYQAmkSMeJJ8UYzehWUfmvCyr1:-Mx1FrYyzNUSrzclZm5q

    Feedback ZIP

    • 3 replies
    1. Hi DJH,

      Does the memory location window pop up when you run this?
      We recommend adding an Activate App's Main Window set to Pro Tools before sending any keystrokes, to ensure the proper target app is active before keystrokes are sent.

      On a wider note:
      Please note that the last 'enter' should be delayed, as it depends on the window being opened before it will make sense for PT to receive that keystroke. SoundFlow sends off keystrokes fairly rapidly, so it might fire off that last enter before the window has appeared.

      I'd highly recommend that you check out these 2 videos on why with SoundFlow you should prefer UI automation over Keyboard simulation whenever possible. It also teaches how to add custom waits that depend on actual UI elements to have become available.

      Generally, with SoundFlow, automating through the keyboard should always be the last resort, as there are almost always better ways to achieve things. In this case, it'd be using the built-in action.

      1. D
        In reply toDJH:
        DJH @DJH
          2022-02-28 22:31:28.072Z

          Yay! The activate main window App did the trick! Thanks! That's a great thing to keep in mind - I'm currently using on-screen SF deck and it just occurred how clicking a button might actually disconnect a command from pro tools BC it essentially activates another app.

          Understood about wait for UI element and using press keys as a last resort...(though it is handy to make something on he fly when you already know a shortcut).

          What is the functional difference between "activate app" and "activate apps main window"?

          1. Awesome! The Activate App's Main Window will simulate a mouse click on the title bar of the window and so works more reliably to ensure Pro Tools is in the right state. We might be able to remove the mouse click in the future. But yea, the Activate App due to how macOS processes "active apps" might be too little to properly get focus and menu items in the right state so the AA's Main Window is the preferred action to use for most scenarios.