I have this macro that clicks a GUI button in Pro Tools. However that same button has different options if the user holds down command and clicks it, or holds down command and control and clicks it. Is there any way that I can achieve this in KM?
Below is the code from the apple script used to click the button I have also included the macro as well.
-- Attempt to click the "Insert Assignment A" button for the track
try
click (button "Insert Assignment A" of group "Inserts A-E" of UI element trackName of mainWindow)
on error
try
set mixWindow to first window whose name starts with "Mix:"
click (button "Insert Assignment A" of group "Inserts A-E" of UI element trackName of mixWindow)
on error
display dialog "Couldn't find or click the correct button for the track."
return
end try
end try
end tell
end tell
Insert - Open Insert Slot A on Selected Track.kmmacros (3.9 KB)
Ok Nevermind I figured it out. The solution was to change the script to export coordinates of the button, then use KM to split the coordinates into two variables and then use the Click at position using those variables.Which of course the click at position allows you to hold down key modifiers!
This might also work:
tell application "System Events"
-- Attempt to cmd-click the "Insert Assignment A" button for the track
try
key down command
click (button "Insert Assignment A" of group "Inserts A-E" of UI element trackName of mainWindow)
key up command
on error
try
set mixWindow to first window whose name starts with "Mix:"
key down command
click (button "Insert Assignment A" of group "Inserts A-E" of UI element trackName of mixWindow)
key up command
on error
key up command -- Make sure to release the command key if an error occurs
display dialog "Couldn't find or click the correct button for the track."
return
end try
end try
end tell
1 Like
Thank you so much. I was trying that same thing initially, however Pro Tools just was not registering it as a click. I think applescript might not continue to hold the key down during the click.