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
  #231  
Old 09-21-2019, 12:15 AM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 9
Default Re: Automation AppleScripts for Pro Tools (Mac)

Hi all,

The shift modifier still doesn't work. Everything else is spot on, the script correctly selects the markers and proceeds to click all the buttons. However the Shift is not held down, hence the selection is not made.

I am wondering if I have missed a particular setting for System Events to respond to that command? Weirdly enough, in Settings - Security & Privacy - Privacy I have System Events, Automator and even the particular script enabled.

Any pointers would be greatly appreciated!
Reply With Quote
  #232  
Old 09-21-2019, 12:54 AM
henningaround henningaround is offline
Member
 
Join Date: Feb 2012
Location: Cologne, Germany
Posts: 74
Default Re: Automation AppleScripts for Pro Tools (Mac)

Try using just one memory location with a selection so you don't need a shift click.
Reply With Quote
  #233  
Old 09-21-2019, 01:21 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 961
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by echoesoflife View Post
Hi all,

The shift modifier still doesn't work. Everything else is spot on, the script correctly selects the markers and proceeds to click all the buttons. However the Shift is not held down, hence the selection is not made.

I am wondering if I have missed a particular setting for System Events to respond to that command? Weirdly enough, in Settings - Security & Privacy - Privacy I have System Events, Automator and even the particular script enabled.

Any pointers would be greatly appreciated!
Weird. Post your complete script and I will have a look. The shift click should work fine. I use such a script (to make a selection from top to end of session) daily and it never fails.
Reply With Quote
  #234  
Old 09-21-2019, 08:13 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 9
Default Re: Automation AppleScripts for Pro Tools (Mac)

Thank you Oliver.

Here's the current version of my complicated Memory Location selection.

I see the script clicking on markers correctly, but the Shift is not engaged during the process.

Interestingly enough, today I am experiencing Shift being engaged after the script has finished. Even though it is wrapped around try code.

When I am trying the version of the selection that you have suggested, the script would not click on any of the markers.

It is worth noting that I am using a Hackintosh system, and I am on High Sierra.

Thanks again for your time!

Code:
property shortDelay : 0.1

on doWithTimeout(uiScript, timeoutSeconds)
	set endDate to (current date) + timeoutSeconds
	repeat
		try
			run script "tell application \"System Events\"
" & uiScript & "
end tell"
			exit repeat
		on error errorMessage
			if ((current date) > endDate) then
				error "Can not " & uiScript
			end if
		end try
	end repeat
end doWithTimeout


activate application "Pro Tools"
set timeoutSeconds to 0.2

-- Click the “Window” menu.
delay 0.4
set uiScript to "click menu bar item \"Window\" of menu bar 1 of application process \"Pro Tools\""
my doWithTimeout(uiScript, timeoutSeconds)

-- Memory Locations
delay 0.5
set uiScript to "click menu item \"Memory Locations\" of menu \"Window\" of menu bar item \"Window\" of menu bar 1 of application process \"Pro Tools\""
my doWithTimeout(uiScript, timeoutSeconds)
end run



--selection of markers from Start to End script




tell application "System Events"
	tell process "Pro Tools"
		
		set asWindow to (1st window whose name contains "Memory Locations")
		
		try
			key down {shift}
			tell asWindow
				
				-- 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 click static text "Start" of UI element 2 of aRow
				end repeat
				
				-- click "End"
				
				delay shortDelay
				
				repeat with aRow in row of table "Memory Locations"
					if name of static text of UI element 2 of aRow starts with "End" then click static text "End" of UI element 2 of aRow
				end repeat
				
				
			end tell
			delay shortDelay
			
			
			key up {shift}
			
			
		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
	
end tell



-- Press ⌥⌘B

delay 0.5
set uiScript to "keystroke \"∫\" using {option down, command down}"
my doWithTimeout(uiScript, timeoutSeconds)

-- Click the “Offline” checkbox.
set uiScript to "click checkbox \"Offline\" of window \"Bounce\" of application process \"Pro Tools\""

-- Click the “Bounce” button.
set uiScript to "click UI Element \"Bounce\" of window \"Bounce\" of application process \"Pro Tools\""
my doWithTimeout(uiScript, timeoutSeconds)

-- Click the “OK” button.
set uiScript to "click UI Element \"OK\" of window \"MP3\" of application process \"Pro Tools\""
end run

Last edited by echoesoflife; 09-22-2019 at 10:11 PM.
Reply With Quote
  #235  
Old 09-23-2019, 01:48 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 961
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by echoesoflife View Post
Thank you Oliver.

Here's the current version of my complicated Memory Location selection.

I see the script clicking on markers correctly, but the Shift is not engaged during the process.

Interestingly enough, today I am experiencing Shift being engaged after the script has finished. Even though it is wrapped around try code.

When I am trying the version of the selection that you have suggested, the script would not click on any of the markers.

It is worth noting that I am using a Hackintosh system, and I am on High Sierra.

Thanks again for your time!

Code:
property shortDelay : 0.1

on doWithTimeout(uiScript, timeoutSeconds)
	set endDate to (current date) + timeoutSeconds
	repeat
		try
			run script "tell application \"System Events\"
" & uiScript & "
end tell"
			exit repeat
		on error errorMessage
			if ((current date) > endDate) then
				error "Can not " & uiScript
			end if
		end try
	end repeat
end doWithTimeout


activate application "Pro Tools"
set timeoutSeconds to 0.2

-- Click the “Window” menu.
delay 0.4
set uiScript to "click menu bar item \"Window\" of menu bar 1 of application process \"Pro Tools\""
my doWithTimeout(uiScript, timeoutSeconds)

-- Memory Locations
delay 0.5
set uiScript to "click menu item \"Memory Locations\" of menu \"Window\" of menu bar item \"Window\" of menu bar 1 of application process \"Pro Tools\""
my doWithTimeout(uiScript, timeoutSeconds)
end run



--selection of markers from Start to End script




tell application "System Events"
	tell process "Pro Tools"
		
		set asWindow to (1st window whose name contains "Memory Locations")
		
		try
			key down {shift}
			tell asWindow
				
				-- 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 click static text "Start" of UI element 2 of aRow
				end repeat
				
				-- click "End"
				
				delay shortDelay
				
				repeat with aRow in row of table "Memory Locations"
					if name of static text of UI element 2 of aRow starts with "End" then click static text "End" of UI element 2 of aRow
				end repeat
				
				
			end tell
			delay shortDelay
			
			
			key up {shift}
			
			
		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
	
end tell



-- Press ⌥⌘B

delay 0.5
set uiScript to "keystroke \"∫\" using {option down, command down}"
my doWithTimeout(uiScript, timeoutSeconds)

-- Click the “Offline” checkbox.
set uiScript to "click checkbox \"Offline\" of window \"Bounce\" of application process \"Pro Tools\""

-- Click the “Bounce” button.
set uiScript to "click UI Element \"Bounce\" of window \"Bounce\" of application process \"Pro Tools\""
my doWithTimeout(uiScript, timeoutSeconds)

-- Click the “OK” button.
set uiScript to "click UI Element \"OK\" of window \"MP3\" of application process \"Pro Tools\""
end run
You are still using your old code to make the selection, which doesn't work. Click your start and end positions by number, try the example I posted in post #229.
Reply With Quote
  #236  
Old 09-23-2019, 10:08 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 961
Default Re: Automation AppleScripts for Pro Tools (Mac)

echoesoflife,

here is a combination of cliclick and the key down and up commands that does what you want (it clicks the actual markers by name).
I also added some code to check whether the Memory Locations window is open and if not opens it.
This works flawlessly here.

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

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

tell application "System Events"
	tell process "Pro Tools"
		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
				-- Click "Start" marker
				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" marker and extend selection
				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
	end tell
end tell

on cliClick(process)
	do shell script quoted form of cliclickCLIPath & " -r " & process
end cliClick
I have no idea what your extra uiScript does but if the above code still fails on your machine then I suggest to have a look at that particular script.

Last edited by Oliver M; 09-24-2019 at 07:01 AM. Reason: Corrected/added a few comments.
Reply With Quote
  #237  
Old 09-24-2019, 02:48 AM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 9
Default Re: Automation AppleScripts for Pro Tools (Mac)

Works like a charm, thanks kindly!

I am going to finish the script into a little app where you could select Online/Offline Bounce, Bounce location and select a few projects to bounce.

Once I am done, I will share the source code and the app here.
__________________
Pro Tools 2019, Hackintosh High Sierra
Reply With Quote
  #238  
Old 09-26-2019, 02:58 PM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 961
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by echoesoflife View Post
Works like a charm, thanks kindly!

I am going to finish the script into a little app where you could select Online/Offline Bounce, Bounce location and select a few projects to bounce.

Once I am done, I will share the source code and the app here.
I am looking forward to this.
Reply With Quote
  #239  
Old 10-01-2019, 04:02 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 9
Default Re: Automation AppleScripts for Pro Tools (Mac)

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
__________________
Pro Tools 2019, Hackintosh High Sierra
Reply With Quote
  #240  
Old 10-03-2019, 02:13 AM
clancychris clancychris is offline
Member
 
Join Date: Nov 2010
Location: Lancashire, UK
Posts: 77
Default Re: Automation AppleScripts for Pro Tools (Mac)

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.
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 04:25 AM
Pro Tools 11.2.1 Automation Bug?! Gneal550 Pro Tools 11 1 11-22-2014 01:15 PM
GRM tools automation bug? D'Animation Pro Tools TDM Systems (Mac) 6 10-08-2014 08:21 AM
scripting Pro Tools; automation Bermaster 003, Mbox 2, Digi 002, original Mbox, Digi 001 (Mac) 12 10-01-2004 12:38 PM
AppleScripts and other Macros for PT Bergeron Tips & Tricks 1 11-15-1999 06:55 PM


All times are GMT -7. The time now is 07:58 PM.


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