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-20-2019, 01:41 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 994
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by echoesoflife View Post
...
Here is the part of the code where Shift modifier doesn't work:
...
Quote:
Originally Posted by henningaround View Post
Maybe you can avoid this by using a memory locations with a selection which always has the number 999. So you can locate to it by hitting ,999, on the keypad (inside your script).
echoesoflife,

what Henning wrote is the easiest solution.
If you want to pick specific Memory Locations (i.e. Start is marker #1 and End is marker #999) you can do it like that:

Code:
property shortDelay : 0.1
property medDelay : 0.3

tell application "System Events"
	tell process "Pro Tools"
		set frontmost to true
		-- Select Marker #1 - Top
		key code 65 -- , key
		keystroke "1"
		key code 65
		delay medDelay
		-- Extend selection to Marker #999 - End
		try
			key down {shift}
			delay shortDelay
			key code 65
			keystroke "999"
			key code 65
			delay shortDelay
			key up {shift}
		end try
	end tell
end tell
The Memory Locations window doesn't even have to be open for this to work.

Keep in mind that you should wrap the key down and up commands in a try block as those keys can get stuck!
Reply With Quote
  #232  
Old 09-20-2019, 02:12 AM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 15
Default Re: Automation AppleScripts for Pro Tools (Mac)

Thank you kindly! I'll give it a try and will report back then.
Reply With Quote
  #233  
Old 09-21-2019, 12:15 AM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 15
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
  #234  
Old 09-21-2019, 12:54 AM
henningaround henningaround is offline
Member
 
Join Date: Feb 2012
Location: Cologne, Germany
Posts: 95
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
  #235  
Old 09-21-2019, 01:21 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 994
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
  #236  
Old 09-21-2019, 08:13 PM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 15
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
  #237  
Old 09-23-2019, 01:48 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 994
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
  #238  
Old 09-23-2019, 04:41 AM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 15
Default Re: Automation AppleScripts for Pro Tools (Mac)

Thanks Oliver.

Yes, indeed.

I did try your suggestion, and the markers are not getting selected.

Here's the code that I tried:
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



--selection of markers from Start to End script


property medDelay : 0.3

tell application "System Events"
	tell process "Pro Tools"
		set frontmost to true
		-- Select Marker #1 - Top
		key code 65 -- , key
		keystroke "1"
		key code 65
		delay medDelay
		-- Extend selection to Marker #999 - End
		try
			key down {shift}
			delay shortDelay
			key code 65
			keystroke "999"
			key code 65
			delay shortDelay
			key up {shift}
		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
__________________
Pro Tools 2019, Hackintosh High Sierra
Reply With Quote
  #239  
Old 09-23-2019, 10:08 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 994
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
  #240  
Old 09-24-2019, 02:48 AM
echoesoflife echoesoflife is offline
Member
 
Join Date: Aug 2019
Location: Melbourne, Australia
Posts: 15
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
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 11:31 AM.


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