Applescript in Pro Tools

Hi All,


I'm fairly new tho Applescript, but have been playing around with it to try and speed up my workflow on some software I use for work called Pro Tools.


Basically, quite often there is a very monotonous task I need to do, which is cycle through large amounts of "markers" (200-300+ sometimes) and press V, then K, then move onto the next and repeat. I'm trying to create an applescript to speed this up for me. To move to markers you type ".1." (without quotations) for example and that will take you to marker number 1, where I then need to press V, K then type ".2." to move to marker 2 and so on.


My script is working, but needs some tweaks.


tell application "Pro Tools"

activate


--Display Dialog and Get Input

display dialog "How many markers?" default answer ""


tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "1"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "v"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "k"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "2"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "v"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "k"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "3"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "v"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "k"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "4"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "v"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "k"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "5"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "v"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "k"


end tell

So this shows my script that works up to Marker 5, then ends. This is my first "working" script, so its probably very messy/inefficient!


The display dialog in there at the moment does nothing, but ideally I'd like to be able to type how many markers I have in there. And then have the script type in the process for me, up until the number of which I typed in. So for example, if I typed in that I have 157 markers, it would repeat the process up until marker 157, and then stop.


Is there a way I'm missing to achieve this? Or is it too complicated/going about this in a very stupid way?


Thanks!

MacBook Pro (15-inch Mid 2012), iOS 8

Posted on Sep 18, 2014 2:01 PM

Reply
4 replies

Sep 18, 2014 2:08 PM in response to Rockthekasper

Try using:


set num_markers to text returned of (display dialog "How many markers?" default answer "") as number

repeat with this_marker from 1 to num_markers

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

repeat with this_item in (this_marker as string)

tell application "System Events" to tell process "Pro Tools" to keystroke (this_item as string)

delay 0.02

end repeat

end tell

tell application "System Events" to tell process "Pro Tools" to keystroke "."

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "v"

delay 0.02

tell application "System Events" to tell process "Pro Tools" to keystroke "k"

end repeat


(113104)

Sep 18, 2014 2:22 PM in response to Niel

That was very helpful! I've changed ProTools to TextEdit, just so I can see what the keystrokes translate too. So this script...


tell application "TextEdit"

activate


--Display Dialog and Get Input

display dialog "How many markers?" default answer ""


set num_markers to text returned of (display dialog "How many markers?" default answer "") as number

repeat with this_marker from 1 to num_markers

tell application "System Events" to tell process "TextEdit" to keystroke "."

delay 0.02

repeat with this_item in (this_marker as string)

tell application "System Events" to tell process "TextEdit" to keystroke (this_item as string)

delay 0.02

end repeat

end repeat


tell application "System Events" to tell process "TextEdit" to keystroke "."

delay 0.02

tell application "System Events" to tell process "TextEdit" to keystroke "v"

delay 0.02

tell application "System Events" to tell process "TextEdit" to keystroke "k"


end tell


...Translates as this in TextEdit when I type in 20 in the "How many markers" box...


.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.vk


Where I need it to type


.1.vk.2.vk.3.vk.4.vk.5.vk.6.vk.7.vk.8.vk.9.vk.10.vk.11vk.12.vk.13.vk.14.vk.15.vk.16.vk.17.vk.18.vk.19.vk.20.vk


Any ideas?


Thanks for the help though! I'm getting there (slowly)

Sep 18, 2014 2:27 PM in response to Rockthekasper

Here:


tell application "TextEdit"

activate

--Display Dialog and Get Input

set num_markers to text returned of (display dialog "How many markers?" default answer "") as number

repeat with this_marker from 1 to num_markers

tell application "System Events" to tell process "TextEdit" to keystroke "."

delay 0.02

repeat with this_item in (this_marker as string)

tell application "System Events" to tell process "TextEdit" to keystroke (this_item as string)

delay 0.02

end repeat

tell application "System Events" to tell process "TextEdit" to keystroke "."

delay 0.02

tell application "System Events" to tell process "TextEdit" to keystroke "v"

delay 0.02

tell application "System Events" to tell process "TextEdit" to keystroke "k"

end repeat

end tell


(113111)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript in Pro Tools

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.