View Single Post
  #253  
Old 11-03-2019, 04:08 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 15
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by Oliver M View Post
Any progress?
Hi Oliver, thanks for checking in, appreciate it.

Yes, I made some significant progress. The script is still not operational, I am looking to debug it.

Current issues:
- When I open just one file, the script performs well
- When I try opening more than one file, the script wouldn't click Don't Save button. Also sometimes the script wouldn't open Memory Locations - which somehow works for one file

I will spend more time debugging the script.

Here's the current version for the reference:
Code:
property cliclickCLIPath : missing value
property shortDelay : 0.1
property medDelay : 0.3

set cliclickCLIPath to "usr/local/bin/cliclick"

set theFolders to {}
repeat
	try
		set theFolders to theFolders & (choose file with prompt "Choose your PT files to bounce. Choose Cancel when finished with all folders" with multiple selections allowed)
		get theFolders
	on error
		display notification "Exiting"
		exit repeat
	end try
end repeat
get theFolders

set i to 0
set aRow to 0
set bRow to 0
set mySession to {}


repeat with i from 1 to (count of theFolders)
	set mySession to item i of theFolders
	tell application "Finder" to open mySession using application file id "com.avid.ProTools" as alias
	
	delay shortDelay
	
	tell application "System Events"
		tell process "Pro Tools"
			
			try
				
				set frontmost to true
				
				-- Open Memory Locations window if it is not open already
				
				if not (exists window "Memory Locations") then
					click menu item "Memory Locations" of menu "Window" of menu bar item "Window" of menu bar 1
					
					repeat until exists window "Memory Locations"
						delay shortDelay
					end repeat
				end if
				
				
				-- Set variable for Memory Locations window
				set mlWindow to (1st window whose name contains "Memory Locations")
				
				delay shortDelay
				tell mlWindow
					delay shortDelay

					-- Maximize window
					click button 10 of mlWindow
				
					
					try
						
						-- click "Start"
						set aRow to row 1 of table "Memory Locations"
						tell aRow
							set {xPosition, yPosition} to position
							set {xSize, ySize} to size
							my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
						end tell
						
						
						
						-- click "End"
						
						
						set b to count of row of table "Memory Locations"
						
						set bRow to row b of table "Memory Locations"
						tell bRow
							key down {shift}
							delay shortDelay
							set {xPosition, yPosition} to position
							set {xSize, ySize} to size
							
							my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
							key up {shift}
						end tell
						
						
						
						
						
					on error e number n
						tell application "Pro Tools" to display alert "An Error Occurred" message e & " (" & n & ")" buttons {"Cancel"} default button 1
					end try
				end tell
				
				-- Press ⌥⌘B
				tell application "System Events" to key code 11 using {option down, command down}
				
				-- Press "Bounce"
				
				tell application "System Events"
					tell process "Pro Tools"
						try
							-- HERE TO ADD ALL THE VARIABLES
					
							click button "Bounce" of window 1
							
							delay shortDelay
							
							keystroke return
							
							
							
							
							repeat until exists button "Don't Save" of window 1
							end repeat
							
							delay shortDelay
							click button "Don't Save" of window 1
							
							
							
							
							
							
						end try
						
						
						
					end tell
					
				end tell
				--	end repeat
			end try
		end tell
	end tell
	
end repeat






on cliClick(process)
	do shell script quoted form of cliclickCLIPath & " -r " & process
end cliClick
__________________
Pro Tools 2019, Hackintosh High Sierra
Reply With Quote