Avid Pro Audio Community

Avid Pro Audio Community

How to Join & Post  •  Community Terms of Use  •  Help Us Help You

Knowledge Base Search  •  Community Search  •  Learn & Support


Avid Home Page

Go Back   Avid Pro Audio Community > Pro Tools Software > Tips & Tricks

Reply
 
Thread Tools Search this Thread Display Modes
  #251  
Old 10-13-2019, 07:55 PM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 966
Default Re: Automation AppleScripts for Pro Tools (Mac)

Here's some simple code to open a PT session with the Finder:

Code:
set mySession to (path to documents folder as text) & "Pro Tools:mySessions:Test_Session.ptx" as text

tell application "Finder" to open mySession using application file id "com.avid.ProTools" as alias
Reply With Quote
  #252  
Old 11-03-2019, 03:38 PM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 966
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by echoesoflife View Post
Thanks Oliver, duly noted. This makes sense. I will implement these ideas and will report back. Thanks again.
Any progress?
Reply With Quote
  #253  
Old 11-03-2019, 05:08 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 14
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
  #254  
Old 11-17-2019, 07:08 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 14
Default Re: Automation AppleScripts for Pro Tools (Mac)

Hi all,

Looks like I was able to make the first version of the automatic bounce script to work.

Here is the code.

I will continue debugging it and adding small improvements.

Kindly let me know if it's usable on your end. Highly appreciate all your help and attention along the way.

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
	set sessionName to name of (info for mySession) as string
	set sessionNameTrim to trimText(sessionName, ".ptx", "end")
	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"
			
-- TO FINISH HERE - to click Don't Save if PT project is already open

			if exists button "Don't Save" of window 1 then
				click button "Don't Save" of window 1
			end if
			
			
			if i is not equal to 1 then
				if not (exists button "Don't Save" of window 1) then
					repeat until exists button "Don't Save" of window 1
					end repeat
				end if
				click button "Don't Save" of window 1
			end if
			
			
			
			try
				
				set frontmost to true
				
				-- Open Memory Locations window if it is not open already
				
				if not (exists window "Memory Locations") then
					repeat until exists window "Memory Locations"
						click menu item "Memory Locations" of menu "Window" of menu bar item "Window" of menu bar 1
						
						--	key code 87 using {command down}
						
						delay shortDelay
					end repeat
				end if
				
				
				-- Set variable for Memory Locations window
				set mlWindow to (1st window whose name contains "Memory Locations")
				
				-- Maximize Memory Locations window for script to be able to click on each marker
				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
							--	Change name of bounced file to Session Name Trim
							
							set bField to text field 1 of window 1
							tell bField
								delay shortDelay
								set {xPosition, yPosition} to position
								set {xSize, ySize} to size
								
								my cliClick("c:" & xPosition + (xSize div 10) & "," & yPosition + (ySize div 2))
								key code 0 using {command down}
								keystroke sessionNameTrim
								
							end tell
							
							
							click button "Bounce" of window 1
							
							delay shortDelay
							
							keystroke return
							
							-- Wait until bounce finishes
							
							repeat until (static text "Bouncing..." of window 1 exists)
							end repeat
							repeat until not (static text "Bouncing..." of window 1 exists)
							end repeat
							
							
							
							
						end try
						
						
						
						
						
					end tell
					
				end tell
			end try
		end tell
	end tell
	
end repeat

if i is equal to (count of theFolders) then
	tell application "System Events"
		tell process "Pro Tools"
			key code 13 using {shift down, command down}
			repeat until exists button "Don't Save" of window 1
			end repeat
			
			click button "Don't Save" of window 1
		end tell
	end tell
end if



on cliClick(process)
	do shell script quoted form of cliclickCLIPath & " -r " & process
end cliClick


on trimText(theText, theCharactersToTrim, theTrimDirection)
	set theTrimLength to length of theCharactersToTrim
	if theTrimDirection is in {"beginning", "both"} then
		repeat while theText begins with theCharactersToTrim
			try
				set theText to characters (theTrimLength + 1) thru -1 of theText as string
			on error
				-- text contains nothing but trim characters
				return ""
			end try
		end repeat
	end if
	if theTrimDirection is in {"end", "both"} then
		repeat while theText ends with theCharactersToTrim
			try
				set theText to characters 1 thru -(theTrimLength + 1) of theText as string
			on error
				-- text contains nothing but trim characters
				return ""
			end try
		end repeat
	end if
	return theText
end trimText
__________________
Pro Tools 2019, Hackintosh High Sierra
Reply With Quote
  #255  
Old 12-01-2019, 01:32 PM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 966
Default Re: Automation AppleScripts for Pro Tools (Mac)

Hi Michael,

this looks promising. 👍
I will check it out as soon as my time allows. I am usually pretty busy around this time of the year, sorry about that.


Quote:
Originally Posted by echoesoflife View Post
Hi all,

Looks like I was able to make the first version of the automatic bounce script to work.

Here is the code.

I will continue debugging it and adding small improvements.

Kindly let me know if it's usable on your end. Highly appreciate all your help and attention along the way.

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
	set sessionName to name of (info for mySession) as string
	set sessionNameTrim to trimText(sessionName, ".ptx", "end")
	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"
			
-- TO FINISH HERE - to click Don't Save if PT project is already open

			if exists button "Don't Save" of window 1 then
				click button "Don't Save" of window 1
			end if
			
			
			if i is not equal to 1 then
				if not (exists button "Don't Save" of window 1) then
					repeat until exists button "Don't Save" of window 1
					end repeat
				end if
				click button "Don't Save" of window 1
			end if
			
			
			
			try
				
				set frontmost to true
				
				-- Open Memory Locations window if it is not open already
				
				if not (exists window "Memory Locations") then
					repeat until exists window "Memory Locations"
						click menu item "Memory Locations" of menu "Window" of menu bar item "Window" of menu bar 1
						
						--	key code 87 using {command down}
						
						delay shortDelay
					end repeat
				end if
				
				
				-- Set variable for Memory Locations window
				set mlWindow to (1st window whose name contains "Memory Locations")
				
				-- Maximize Memory Locations window for script to be able to click on each marker
				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
							--	Change name of bounced file to Session Name Trim
							
							set bField to text field 1 of window 1
							tell bField
								delay shortDelay
								set {xPosition, yPosition} to position
								set {xSize, ySize} to size
								
								my cliClick("c:" & xPosition + (xSize div 10) & "," & yPosition + (ySize div 2))
								key code 0 using {command down}
								keystroke sessionNameTrim
								
							end tell
							
							
							click button "Bounce" of window 1
							
							delay shortDelay
							
							keystroke return
							
							-- Wait until bounce finishes
							
							repeat until (static text "Bouncing..." of window 1 exists)
							end repeat
							repeat until not (static text "Bouncing..." of window 1 exists)
							end repeat
							
							
							
							
						end try
						
						
						
						
						
					end tell
					
				end tell
			end try
		end tell
	end tell
	
end repeat

if i is equal to (count of theFolders) then
	tell application "System Events"
		tell process "Pro Tools"
			key code 13 using {shift down, command down}
			repeat until exists button "Don't Save" of window 1
			end repeat
			
			click button "Don't Save" of window 1
		end tell
	end tell
end if



on cliClick(process)
	do shell script quoted form of cliclickCLIPath & " -r " & process
end cliClick


on trimText(theText, theCharactersToTrim, theTrimDirection)
	set theTrimLength to length of theCharactersToTrim
	if theTrimDirection is in {"beginning", "both"} then
		repeat while theText begins with theCharactersToTrim
			try
				set theText to characters (theTrimLength + 1) thru -1 of theText as string
			on error
				-- text contains nothing but trim characters
				return ""
			end try
		end repeat
	end if
	if theTrimDirection is in {"end", "both"} then
		repeat while theText ends with theCharactersToTrim
			try
				set theText to characters 1 thru -(theTrimLength + 1) of theText as string
			on error
				-- text contains nothing but trim characters
				return ""
			end try
		end repeat
	end if
	return theText
end trimText
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pro Tools 12 Trim Automation bleu@cheerful.com Pro Tools 12 2 08-16-2015 05:25 AM
Pro Tools 11.2.1 Automation Bug?! Gneal550 Pro Tools 11 1 11-22-2014 02:15 PM
GRM tools automation bug? D'Animation Pro Tools TDM Systems (Mac) 6 10-08-2014 09:21 AM
scripting Pro Tools; automation Bermaster 003, Mbox 2, Digi 002, original Mbox, Digi 001 (Mac) 12 10-01-2004 01:38 PM
AppleScripts and other Macros for PT Bergeron Tips & Tricks 1 11-15-1999 07:55 PM


All times are GMT -7. The time now is 06:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Limited. Forum Hosted By: URLJet.com