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
  #241  
Old 10-04-2019, 03:17 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 964
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by clancychris View Post
Hey all!

I'm pretty new to Applescript (2 days lol) but I'm slowly working out how to do things. I'm trying to script a macro which I can use for recalling track templates for updating multiple sessions, reamping multiple sessions etc. I'm stuck at one point...

I need to open the pop up menu on a defined track name, hit recall preset and select the one I want.

I've managed to navigate to the correct track, I can mute, solo and set to record so I'm halfway there. I've identified the pop up button name etc and I can get it to hit any of these buttons without an issue:

Code:
    
    pop up button "Playlist selector"
    button "Track Record Enable"
    button "TrackInput Monitor"
    button "Solo"
    button "Mute"
    pop up button "Track View selector"
    pop up button "Automation Mode selector"
    pop up button "Track options"

The button I cannot get to work comes up in UIElementInspector as

Code:
pop up button "Track name
        \"Rhythm L\""


Code:
activate application "Pro Tools"
tell application "System Events"
	# Get the frontmost app's *process* object.
	set frontAppProcess to first application process whose frontmost is true
end tell

# Tell the *process* to count its windows and return its front window's name.
tell frontAppProcess
	if (count of windows) > 0 then
		set window_name to name of front window
	end if
end tell

tell application "System Events" to tell process "Pro Tools"
	click pop up button "Track name \"Rhythm L\"" of group "Rhythm L - Audio Track " of window window_name
end tell
When I run the script it says "expected end of line but found identifier"

I'm just so new to this that I've hit a roadblock.
Hi Chris,

click the button by its index but by its name:

Code:
click pop up button 1 of group "Rhythm L - Audio Track " of window window_name
Reply With Quote
  #242  
Old 10-06-2019, 03:04 PM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 964
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by echoesoflife View Post
Hi all,

Making some progress, the script even works for multiple files selected in Automator (surprisingly!) - with a little bit of my help though.

There is one challenge which I couldn't solve yet, and this is regarding dialog windows.

For example, while PT is loading, it may pop up a dialog suggesting that my HUI controller is absent, and the OK button is required to proceed.

I am wondering if any of you have had some luck automatically detecting and pressing "OK", "No" or "Don't Save" buttons in the pop-up dialog windows in Pro Tools.

These windows always go with "window 1" identifier, however once I try to talk to button "OK" of window 1, the script refuses to do so.

Partially this may be because one has to wait until these windows appear, and I don't quite know how to achieve that. I tried repeat until window 1 exists, and this didn't work either.

Any help would be greatly appreciated.

Thanks,
Michael
Look Michael, it is really hard to help if you keep asking questions without explaining in detail what you are after. I have the feeling you want us to complete your code for free only.

You haven't explained what the uiScript does, now you bring Automator stuff in. I have coded stuff for Automator and believe its a nightmare to deal with as its slow like hell. Thus I suggest to avoid it.

You need to explain in detail what you are trying to achieve, step by step. Only then you can expect decent help.

Things like checking for a window to appear has been discussed many times within this thread. Maybe you should start reading it. 😉


No harm intended.
Reply With Quote
  #243  
Old 10-06-2019, 06:32 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 11
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by Oliver M View Post
Look Michael, it is really hard to help if you keep asking questions without explaining in detail what you are after. I have the feeling you want us to complete your code for free only.

You haven't explained what the uiScript does, now you bring Automator stuff in. I have coded stuff for Automator and believe its a nightmare to deal with as its slow like hell. Thus I suggest to avoid it.

You need to explain in detail what you are trying to achieve, step by step. Only then you can expect decent help.

Things like checking for a window to appear has been discussed many times within this thread. Maybe you should start reading it. 😉


No harm intended.
Hello Oliver,

Apologies for the ambiguous answer and description of the problem.

Most certainly not looking for anyone to complete my code for free. Firstly, I am new to programming on AppleScript, hence I am asking for help once I hit a roadblock. I have exhaustively googled the problem that I'm facing and was unable to find any definitive or helpful information.

Secondly, I have searched this thread for the answers (not exhaustively) and implemented some of the solutions regarding the pop up windows with no positive outcome. I have also implemented a few of the solutions (regarding file input, etc.) with positive outcome after hard trial and error, for which I am grateful.

If I am going overboard with requesting this advice, I would happily compensate for one's time. I was actually considering hiring programming services when I started this project.

Hence kindly let me know, and subsequent arrangements will be made with pleasure.

Otherwise here is the description of the complete workflow and the Script that fails to close the pop-up windows (next separate forum message).
__________________
Pro Tools 2019, Hackintosh High Sierra
Reply With Quote
  #244  
Old 10-06-2019, 06:37 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 11
Default Re: Automation AppleScripts for Pro Tools (Mac)

1. Automator. Select the desired Pro Tools Project by using Get Specified Finder Items.
2. Automator. Get Value of Variable.
3. Automator. Run Apple Script (pass the input as arguments).

The following code works properly and does not contain any safety measurements to prevent pop up windows from interrupting the process:

Code:
property cliclickCLIPath : missing value
property shortDelay : 0.1
property medDelay : 0.3

on run {input, parameters}
	set cliclickCLIPath to "usr/local/bin/cliclick"
	
	set SelectedItems to input
	
	
	tell application "System Events"
		tell process "Pro Tools"
			
			try
				
				repeat with x from 1 to count of SelectedItems -- the loop through all selected items
					set theFile to item x of SelectedItems
					tell application "Pro Tools" to open theFile
					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
						try
							my cliClick("c:400,400")
							-- click "Start"
							repeat with aRow in row of table "Memory Locations"
								if name of static text of UI element 2 of aRow starts with "Start" then
									tell static text "Start" of UI element 2 of aRow
										set {xPosition, yPosition} to position
										set {xSize, ySize} to size
										my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
									end tell
								end if
							end repeat
							
							-- click "End"
							repeat with aRow in row of table "Memory Locations"
								if name of static text of UI element 2 of aRow starts with "End" then
									tell static text "End" of UI element 2 of aRow
										set {xPosition, yPosition} to position
										set {xSize, ySize} to size
										key down {shift}
										my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
										key up {shift}
									end tell
								end if
							end repeat
							
						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
								
								if exists (button whose name contains "OK") then
									click button "OK" of window "MP3"
								end if
								
							end try
							
							
							
						end tell
					end tell
					
				end repeat
			end try
		end tell
	end tell
	
	
	
	
	
	return input
end run

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

Next I am trying to add the safety elements which would close the window prompting to save the bounced project, as well as the windows which appear while the project is loading: HUI controller is missing, some I/O are missing.

The beginning of the code:

Code:
property cliclickCLIPath : missing value
property shortDelay : 0.1
property medDelay : 0.3

on run {input, parameters}
	set cliclickCLIPath to "usr/local/bin/cliclick"
	
	set SelectedItems to input
	
	
	
	tell application "System Events"
		tell process "Pro Tools"
			repeat with x from 1 to count of SelectedItems -- the loop through all selected items
				set theFile to item x of SelectedItems
				tell application "Pro Tools" to open theFile
				--		activate application "Pro Tools"
				set frontmost to true
				
				-- Don't Save Button
				
				
				if exists window 1 then
					click button "Don't Save"
					end if
				
				
				
				--SAFETY		
				repeat
					if exists window 1 of application "Pro Tools" then exit repeat
					delay 0.5
				end repeat
				
				if name of static text of window 1 starts with "The original MIDI device" then
					tell button "OK" of window 1 of application "Pro Tools"
						set {xPosition, yPosition} to position
						set {xSize, ySize} to size
						my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
					end tell
				end if
				
				if name of window 1 starts with "Session Notes" then
					tell button "No" of window 1 of application "Pro Tools"
						set {xPosition, yPosition} to position
						set {xSize, ySize} to size
						my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
					end tell
				end if
				
				
				if name of window 1 starts with "Missing Files" then
					tell button "OK" of window 1 of application "Pro Tools"
						set {xPosition, yPosition} to position
						set {xSize, ySize} to size
						my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
					end tell
				end if
				
			end repeat
As far as I understand, the problem is that the script is not trying to continuously detect the pop-up windows, and/or not able to detect the windows before the project has loaded and the main PT window has appeared.

As a result, the required buttons are simply not clicked. If I manually click them, the script continues to bounce just fine.

Any pointers would be greatly appreciated. If this is outside of the normal scope for the discussion, kindly send me a PM to discuss this further.

Thank you,
Michael
__________________
Pro Tools 2019, Hackintosh High Sierra
Reply With Quote
  #245  
Old 10-07-2019, 08:56 AM
clancychris clancychris is offline
Member
 
Join Date: Nov 2010
Location: Lancashire, UK
Posts: 77
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by Oliver M View Post
Hi Chris,

click the button by its index but by its name:

Code:
click pop up button 1 of group "Rhythm L - Audio Track " of window window_name
Thank you so much! I've been tearing my hair out until now lol
Reply With Quote
  #246  
Old 10-11-2019, 09:46 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 964
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by echoesoflife View Post
1. Automator. Select the desired Pro Tools Project by using Get Specified Finder Items.
2. Automator. Get Value of Variable.
3. Automator. Run Apple Script (pass the input as arguments).

The following code works properly and does not contain any safety measurements to prevent pop up windows from interrupting the process:

Code:
property cliclickCLIPath : missing value
property shortDelay : 0.1
property medDelay : 0.3

on run {input, parameters}
	set cliclickCLIPath to "usr/local/bin/cliclick"
	
	set SelectedItems to input
	
	
	tell application "System Events"
		tell process "Pro Tools"
			
			try
				
				repeat with x from 1 to count of SelectedItems -- the loop through all selected items
					set theFile to item x of SelectedItems
					tell application "Pro Tools" to open theFile
					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
						try
							my cliClick("c:400,400")
							-- click "Start"
							repeat with aRow in row of table "Memory Locations"
								if name of static text of UI element 2 of aRow starts with "Start" then
									tell static text "Start" of UI element 2 of aRow
										set {xPosition, yPosition} to position
										set {xSize, ySize} to size
										my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
									end tell
								end if
							end repeat
							
							-- click "End"
							repeat with aRow in row of table "Memory Locations"
								if name of static text of UI element 2 of aRow starts with "End" then
									tell static text "End" of UI element 2 of aRow
										set {xPosition, yPosition} to position
										set {xSize, ySize} to size
										key down {shift}
										my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
										key up {shift}
									end tell
								end if
							end repeat
							
						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
								
								if exists (button whose name contains "OK") then
									click button "OK" of window "MP3"
								end if
								
							end try
							
							
							
						end tell
					end tell
					
				end repeat
			end try
		end tell
	end tell
	
	
	
	
	
	return input
end run

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

Next I am trying to add the safety elements which would close the window prompting to save the bounced project, as well as the windows which appear while the project is loading: HUI controller is missing, some I/O are missing.

The beginning of the code:

Code:
property cliclickCLIPath : missing value
property shortDelay : 0.1
property medDelay : 0.3

on run {input, parameters}
	set cliclickCLIPath to "usr/local/bin/cliclick"
	
	set SelectedItems to input
	
	
	
	tell application "System Events"
		tell process "Pro Tools"
			repeat with x from 1 to count of SelectedItems -- the loop through all selected items
				set theFile to item x of SelectedItems
				tell application "Pro Tools" to open theFile
				--		activate application "Pro Tools"
				set frontmost to true
				
				-- Don't Save Button
				
				
				if exists window 1 then
					click button "Don't Save"
					end if
				
				
				
				--SAFETY		
				repeat
					if exists window 1 of application "Pro Tools" then exit repeat
					delay 0.5
				end repeat
				
				if name of static text of window 1 starts with "The original MIDI device" then
					tell button "OK" of window 1 of application "Pro Tools"
						set {xPosition, yPosition} to position
						set {xSize, ySize} to size
						my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
					end tell
				end if
				
				if name of window 1 starts with "Session Notes" then
					tell button "No" of window 1 of application "Pro Tools"
						set {xPosition, yPosition} to position
						set {xSize, ySize} to size
						my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
					end tell
				end if
				
				
				if name of window 1 starts with "Missing Files" then
					tell button "OK" of window 1 of application "Pro Tools"
						set {xPosition, yPosition} to position
						set {xSize, ySize} to size
						my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
					end tell
				end if
				
			end repeat
As far as I understand, the problem is that the script is not trying to continuously detect the pop-up windows, and/or not able to detect the windows before the project has loaded and the main PT window has appeared.

As a result, the required buttons are simply not clicked. If I manually click them, the script continues to bounce just fine.

Any pointers would be greatly appreciated. If this is outside of the normal scope for the discussion, kindly send me a PM to discuss this further.

Thank you,
Michael
The 1st part of your code is pretty much my code.
But it is just a small part of the entire script, right?

A couple of hints:

Instead of dealing with windows you should prepare your session so that no windows pop up. Checking for open windows and /or pop ups can make a script become real complicated and unstable. Especially because some windows in PT have no name (hint to Avid: Give all PT windows a decent name!!).

But if you really want to go this route then you'll have to add a window counter function which counts windows all the time while the script runs.
This can become really complicated depending on how much windows you wanna watch this way.

IMHO, I'd work with perfectly prepared copies of the sessions and let PT just save the session at the end so that you avoid at least that one dialog window which will eventually always show up after a bounce.

Honestly I am not sure why you have to deal with all the other windows, missing files etc. Just work with a session copy that actually works!

Thats it from me really, because since you still refrain from posting the full script, I cannot help any further, sorry.

Last edited by Oliver M; 10-12-2019 at 05:57 PM. Reason: The smiley in my post was displayed as a ��.s
Reply With Quote
  #247  
Old 10-11-2019, 04:39 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 11
Default Re: Automation AppleScripts for Pro Tools (Mac)

Thanks Oliver, duly noted. This makes sense. I will implement these ideas and will report back. Thanks again.
__________________
Pro Tools 2019, Hackintosh High Sierra
Reply With Quote
  #248  
Old 10-13-2019, 07:55 PM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 964
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
  #249  
Old 11-03-2019, 03:38 PM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 964
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
  #250  
Old 11-03-2019, 05:08 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 11
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
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 04:42 PM.


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