View Single Post
  #235  
Old 09-23-2019, 01:48 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 1,107
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