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
  #211  
Old 09-06-2019, 03:25 AM
henningaround henningaround is offline
Member
 
Join Date: Feb 2012
Location: Cologne, Germany
Posts: 173
Default Re: Automation AppleScripts for Pro Tools (Mac)

I guess it could work this way:
Code:
-- Define Insert to open here
set Insert_to_open to "Insert Assignment A"

tell application "System Events"
	tell process "Pro Tools"
		set frontmost to true
		-- Define the correct Insert group. Maybe there is a more elgant way?
		if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		else if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		else if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		else if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		else if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		end if
		tell (1st window whose title contains "Edit: ")
			
			set selectedTrack to title of button of UI element 2 of (1st row of table "Track List" whose selected is true)
			
			set formattedString to text of selectedTrack as string
			set AppleScript's text item delimiters to "Selected. "
			set theTextItems to every text item of formattedString
			set AppleScript's text item delimiters to ""
			set formattedString to theTextItems as string
			display dialog Insert_to_open
			
			click button Insert_to_open of group Insert_group of group formattedString
			
		end tell
	end tell
end tell
The way to get the selected track into the script was posted here before :) You should be able to use this in a similar way for Solo, Mute, etc.
Reply With Quote
  #212  
Old 09-06-2019, 03:31 AM
henningaround henningaround is offline
Member
 
Join Date: Feb 2012
Location: Cologne, Germany
Posts: 173
Default Re: Automation AppleScripts for Pro Tools (Mac)

OH please kill the line:

Code:
			display dialog Insert_to_open
That was just a help while coding
Reply With Quote
  #213  
Old 09-06-2019, 04:17 AM
TrentWilliams TrentWilliams is offline
Member
 
Join Date: Aug 2012
Location: Wellington, New Zealand
Posts: 985
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by henningaround View Post
OH please kill the line:

Code:
			display dialog Insert_to_open
That was just a help while coding
Wow, this works .. !!

Amazing, thank you sooooo much. I really, really appreciate this.

I can interchange this script for Inserts/Sends, so this helps a lot.

Is there anyway to speed up the script? At the minute its taking a second or two to open the windows.
__________________
Pro Tools 2024.3.0|Perpetual • MTRX Studio • HDX1 • Sync-X • S3 • Dock • Mac Mini 2018 - 3.2GHz i7 6-core macOS 13.6 • RAM 64GB DDR4 GPU AMD 6900XT 16GB • Monitor LG 32UL950-W
Reply With Quote
  #214  
Old 09-06-2019, 04:42 AM
henningaround henningaround is offline
Member
 
Join Date: Feb 2012
Location: Cologne, Germany
Posts: 173
Default Re: Automation AppleScripts for Pro Tools (Mac)

I don't know, I'm really not an Applescript Pro... I think it's been mentioned here, that this is just the way applescript works. Maybe the guys at SoundFlow know a better way ;-)
Reply With Quote
  #215  
Old 09-06-2019, 05:04 AM
TrentWilliams TrentWilliams is offline
Member
 
Join Date: Aug 2012
Location: Wellington, New Zealand
Posts: 985
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by henningaround View Post
I don't know, I'm really not an Applescript Pro... I think it's been mentioned here, that this is just the way applescript works. Maybe the guys at SoundFlow know a better way ;-)
Thanks anyway,

This is truly amazing.

I wonder how it would work in javascript?
__________________
Pro Tools 2024.3.0|Perpetual • MTRX Studio • HDX1 • Sync-X • S3 • Dock • Mac Mini 2018 - 3.2GHz i7 6-core macOS 13.6 • RAM 64GB DDR4 GPU AMD 6900XT 16GB • Monitor LG 32UL950-W
Reply With Quote
  #216  
Old 09-08-2019, 10:00 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 1,103
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by henningaround View Post
I guess it could work this way:
Code:
-- Define Insert to open here
set Insert_to_open to "Insert Assignment A"

tell application "System Events"
	tell process "Pro Tools"
		set frontmost to true
		-- Define the correct Insert group. Maybe there is a more elgant way?
		if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		else if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		else if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		else if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		else if (Insert_to_open = "Insert Assignment A") then
			set Insert_group to "Inserts A-E"
		end if
		tell (1st window whose title contains "Edit: ")
			
			set selectedTrack to title of button of UI element 2 of (1st row of table "Track List" whose selected is true)
			
			set formattedString to text of selectedTrack as string
			set AppleScript's text item delimiters to "Selected. "
			set theTextItems to every text item of formattedString
			set AppleScript's text item delimiters to ""
			set formattedString to theTextItems as string
			display dialog Insert_to_open
			
			click button Insert_to_open of group Insert_group of group formattedString
			
		end tell
	end tell
end tell
The way to get the selected track into the script was posted here before :) You should be able to use this in a similar way for Solo, Mute, etc.
Great stuff Henning. Just keep in mind that the script will fail if no track is selected. So an on error check is needed. 😉
Reply With Quote
  #217  
Old 09-08-2019, 11:13 AM
henningaround henningaround is offline
Member
 
Join Date: Feb 2012
Location: Cologne, Germany
Posts: 173
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by Oliver M View Post
Great stuff Henning. Just keep in mind that the script will fail if no track is selected. So an on error check is needed.
Yeah, you're right. That's were one can see that I don't write the code myself but copy and paste stuff together and modify it until it works
Reply With Quote
  #218  
Old 09-09-2019, 05:38 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 1,103
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by henningaround View Post
Yeah, you're right. That's were one can see that I don't write the code myself but copy and paste stuff together and modify it until it works
There's nothing wrong with that. 😉

Here's a cleaned up version with error checking.

Code:
if ptIsRunning() then
	-- Define Insert to open here
	set Insert_to_open to "Insert Assignment A"
	
	tell application "System Events"
		tell process "Pro Tools"
			set frontmost to true
			-- Define the correct Insert group
			if (Insert_to_open = "Insert Assignment A") then
				set Insert_group to "Inserts A-E"
			end if
			
			tell (1st window whose title contains "Edit: ")
				try
					set selectedTrack to title of button of UI element 2 of (1st row of table "Track List" whose selected is true)
					set formattedString to text of selectedTrack as string
					set AppleScript's text item delimiters to "Selected. "
					set theTextItems to every text item of formattedString
					set AppleScript's text item delimiters to ""
					set formattedString to theTextItems as string
					
				on error e number n
					if the n is -1719 then
						tell application "Pro Tools" to display alert "No track was selected." message " " buttons {"Cancel"} default button 1
						return
					else
						tell application "Pro Tools" to display alert "An Error Occurred" message e & " (" & n & ")" buttons {"Cancel"} default button 1
					end if
				end try
				
				if exists (button Insert_to_open of group Insert_group of group formattedString) then
					click button Insert_to_open of group Insert_group of group formattedString
				else
					return
				end if
			end tell
		end tell
	end tell
end if

on ptIsRunning()
	return application "Pro Tools" is running
end ptIsRunning
Reply With Quote
  #219  
Old 09-11-2019, 12:08 AM
henningaround henningaround is offline
Member
 
Join Date: Feb 2012
Location: Cologne, Germany
Posts: 173
Default Re: Automation AppleScripts for Pro Tools (Mac)

Oh thanks a lot. I have to implement that. Scripts get longer and longer...! Are you just using AppleScripts directly mapped to a keystroke? I'm using a combination of Keyboard Maestro and AppleScript right now. In Keyboard Maestro I specify variable or ask for Input (e.g. an AudioSuite Plug-In or an Insert to open) and give it to an Applescript to perform the action.
Reply With Quote
  #220  
Old 09-11-2019, 02:31 AM
Oliver M Oliver M is offline
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 1,103
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by henningaround View Post
Oh thanks a lot. I have to implement that. Scripts get longer and longer...! Are you just using AppleScripts directly mapped to a keystroke? I'm using a combination of Keyboard Maestro and AppleScript right now. In Keyboard Maestro I specify variable or ask for Input (e.g. an AudioSuite Plug-In or an Insert to open) and give it to an Applescript to perform the action.
Most of the time I use AppleScript Bundles triggered by FastScripts via keyboard shortcuts but of course you can use any combination that works for you.
Sometimes I compile AppleScripts as apps, where it makes sense.
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 [email protected] 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 05:38 AM.


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