Keystroke after Applescript is delayed significantly (Pro Tools)

Hello,

I've been looking for a way to create shortcuts for a particular window in Pro Tools (the Quantize window in Event Operations, if anyone is familiar). I wrote a couple Applescripts that work in getting the window and a drop down menu open, and it works extremely well and is consistent.

However, I wanted to add a keystroke in the KM macro after the scripts to cycle through some of the items in the drop down menu before pressing Return to select one. When I add the "Type a Keystroke" action after my scripts, the keystroke is delayed, it seems by up to 7 seconds.

Without the Keystroke action, the script runs instantly and the drop down menu is accessed, but adding just the Keystroke action causes the desired action to lag. I tried adding a "key code" command in the script itself, but that is having the same effect. I've also tried running the script in a few other applications (Fastscripts and Script Editor) and I'm getting the same result.

Is there some preference in KM that I'm not aware of that would cause this issue, or could it be with Pro Tools itself? All my other KM macros, some of which have up to 20 keystrokes, don't have this lag at all and execute immediately. It seems there is something about having a keystroke after a script that causes something (KM, Pro Tools?) to lag for a few seconds.

I'm running a Mac Pro 5,1 2 x 2.66 GHz OSX 10.12.6, Keyboard Maestro v8.2.4

Hey @alexskish,

This is an unfortunate behavior of applications whose accessibility features have been poorly written.

You run the click event, and the script-runner is waiting for an event to be returned – and the app either doesn't send it and times-out – or it sends it late.

Usually about 6-7 seconds.

You might be able to enclose your script in the following:

ignoring application responses
   # Do something
end ignoring

This might work, or it might cause the script to just fail.

-Chris

@ccstone thanks for your reply. I'll be able to try your recommendation later today. Would the "ignore" script lines be placed at the very beginning and end of the script, or just around the "click" line?

I think I'd try the click line first and experiment.

-Chris

Applescript and System Events in Pro Tools are not a happy marriage. Especially when your session gets bigger the delays are terrible. Avoid Applescript as much as possible. Image Search within KM is much quicker, although you would not expect that.

For the above macro, maybe use the KM action Press Button instead.

I have same problem, script is waiting for response from PT so it delays 5+ seconds after clicking a pop up button. You also cannot directly select anything inside the pop up via normal Applescript methods because pro tools doesn't follow conventions.

You CAN add ignoring application responses within the script editor and it runs without the delay, however pasting that script into KM script execution macro fails with not explanation. I can also save the script from the editor (where it works fine) into a file and trigger that via KM and it also fails...

The KM PRESS BUTTON action cannot find the audiosuite window buttons by name (even though these are the names that work in Applescript and show up in Accessibility Inspector)... so that's a bust too.

The only solution I've found is to use apple script to quiery the current window location and then send a click based on the window location (this makes it agnostic to where the window is on screen and can click the right field every time). Not as elegant as a direct scripting solution but faster than image searching.

Did you ever find a solution to this issue? I’m running across the same issue that I just posted about today.

no solution. I doubt it will ever come.