View Single Post
  #272  
Old 05-08-2020, 04:53 AM
Oliver M Oliver M is online now
Member
 
Join Date: Dec 1969
Location: Europe
Posts: 1,108
Default Re: Automation AppleScripts for Pro Tools (Mac)

Quote:
Originally Posted by oudi View Post
hi
the problem is the button 1 is not each time the close button...it depand of the plug
and it's not AudioSuite but Audio Suite.
for example
for the channel strip plug the close button is the 11




Code:
activate application "Pro Tools"
tell application "System Events"
    tell process "Pro Tools"
        tell (every window whose name contains "Audio Suite") to click button 11 -- Close button
    end tell
 end tell
and button 9 for normalize plug....
Exactly! 😉
Some years ago -when Avid introduced these changes-, I updated my own personel script so that it reads the close button ID's from a property list. I haven't updated it for a while but it should work up until PT 2019.12 at least.

Code:
--	Close Every AudioSuite Window in Pro Tools

--	This script closes every open AudioSuite plug-in in Avid Pro Tools.


--	Version History:

--	v4.0:	Due to code changes in Pro Tools 12.8.2 AudioSuite plug-in close buttons no longer use the static index ID 1 but inconsistent IDs. Because of this the ID of an open AS plug-in window's close button will be picked from a property list.

--	v3.0:	Minimum requirements for this version are macOS 10.12 or higher, Pro Tools 12.7 or higher.
--			Got rid of old code for older OS and PT versions.
--			Added a check to determine if there is actually an AudioSuite window open (dummy check).

--	v2.2:	Minor code changes.

--	v2.1:	Minor code changes.		

--	v2.0:	Turned AppleScript into an AppleScript Bundle.

--	v1.0:	For personal use only.


--  Copyright (c) 2014-2017 Oliver Momm. All rights reserved.

property shortDelay : 0.1
property medDelay : 0.3
property longDelay : 0.5
property xtralongDelay : 1

property buttonData : {{name:"C4 Stereo", identifier:11}, ¬
	{name:"C6 Stereo", identifier:11}, ¬
	{name:"Channel Strip", identifier:11}, ¬
	{name:"D-Verb", identifier:12}, ¬
	{name:"DC Offset Removal", identifier:9}, ¬
	{name:"DeEsser Stereo", identifier:11}, ¬
	{name:"Devil-Loc Deluxe", identifier:11}, ¬
	{name:"Doubler2 Stereo", identifier:11}, ¬
	{name:"Doubler4 Stereo", identifier:11}, ¬
	{name:"Duplicate", identifier:10}, ¬
	{name:"Elixir v3 - 1 Stage", identifier:11}, ¬
	{name:"Elixir v3", identifier:11}, ¬
	{name:"EQ3 1-Band", identifier:11}, ¬
	{name:"EQ3 7-Band", identifier:11}, ¬
	{name:"Gain", identifier:7}, ¬
	{name:"GRM BandPass", identifier:11}, ¬
	{name:"GRM CombFilter", identifier:11}, ¬
	{name:"GRM Contrast", identifier:11}, ¬
	{name:"GRM Delays", identifier:12}, ¬
	{name:"GRM Doppler", identifier:11}, ¬
	{name:"GRM Equalize", identifier:11}, ¬
	{name:"GRM Freeze", identifier:11}, ¬
	{name:"GRM PitchAccum", identifier:11}, ¬
	{name:"GRM Reson", identifier:11}, ¬
	{name:"GRM Shift", identifier:11}, ¬
	{name:"GRM Shuffling", identifier:12}, ¬
	{name:"GRM Warp", identifier:11}, ¬
	{name:"HoRNetSongKeyMK2", identifier:11}, ¬
	{name:"Invert", identifier:10}, ¬
	{name:"IRCAM Tools - T.R.A.X. CS v3", identifier:11}, ¬
	{name:"IRCAM Tools - T.R.A.X. SF v3", identifier:11}, ¬
	{name:"IRCAM Tools - T.R.A.X. Tr. v3", identifier:11}, ¬
	{name:"iZotope DDLY", identifier:12}, ¬
	{name:"iZotope RX 5 Connect", identifier:10}, ¬
	{name:"iZotope RX 5 De-click", identifier:11}, ¬
	{name:"iZotope RX 5 De-clip", identifier:11}, ¬
	{name:"iZotope RX 5 De-crackle", identifier:11}, ¬
	{name:"iZotope RX 5 De-hum", identifier:11}, ¬
	{name:"iZotope RX 5 De-noise", identifier:11}, ¬
	{name:"iZotope RX 5 De-reverb", identifier:11}, ¬
	{name:"iZotope RX 5 Dialogue De-noise", identifier:11}, ¬
	{name:"L1+ Ultramaximizer Stereo", identifier:11}, ¬
	{name:"L2 Stereo", identifier:11}, ¬
	{name:"Lo-Fi", identifier:11}, ¬
	{name:"LoAir Stereo", identifier:11}, ¬
	{name:"Massenburg Design Works EQ5 3 Bands", identifier:11}, ¬
	{name:"Massenburg Design Works EQ5 5 Bands", identifier:11}, ¬
	{name:"MetaFilter Stereo", identifier:12}, ¬
	{name:"MetaFlanger Stereo", identifier:11}, ¬
	{name:"Mod Delay III", identifier:12}, ¬
	{name:"MondoMod Stereo", identifier:11}, ¬
	{name:"Normalize", identifier:5}, ¬
	{name:"Oxford Dynamics Full", identifier:11}, ¬
	{name:"Oxford Dynamics Surround", identifier:11}, ¬
	{name:"Oxford Envolution", identifier:11}, ¬
	{name:"Oxford EQ+Filters", identifier:11}, ¬
	{name:"Oxford Inflator", identifier:11}, ¬
	{name:"Oxford Limiter", identifier:11}, ¬
	{name:"Oxford Reverb", identifier:12}, ¬
	{name:"Oxford SuprEsser HighRes", identifier:11}, ¬
	{name:"Oxford SuprEsser LowLatency", identifier:11}, ¬
	{name:"Oxford SuprEsser", identifier:11}, ¬
	{name:"Oxford TransMod", identifier:11}, ¬
	{name:"Pitch 'n Time Pro", identifier:12}, ¬
	{name:"Pitch II", identifier:11}, ¬
	{name:"Pitch Shift Legacy", identifier:11}, ¬
	{name:"Pro Limiter Loudness Analyzer", identifier:11}, ¬
	{name:"Q10 Stereo", identifier:11}, ¬
	{name:"Recti-Fi", identifier:11}, ¬
	{name:"Reverse", identifier:10}, ¬
	{name:"S1 Imager Stereo", identifier:11}, ¬
	{name:"S1 MS Matrix Stereo", identifier:11}, ¬
	{name:"S1 Shuffler Stereo", identifier:11}, ¬
	{name:"SA2 Dialog Processor", identifier:11}, ¬
	{name:"Sci-Fi", identifier:11}, ¬
	{name:"Signal Generator", identifier:11}, ¬
	{name:"Space", identifier:12}, ¬
	{name:"SuperTap 6-Taps Stereo", identifier:12}, ¬
	{name:"Time Compression Expansion", identifier:9}, ¬
	{name:"Time Shift", identifier:11}, ¬
	{name:"Vari-Fi", identifier:10}}

set finderIconPath to (path to library folder from system domain as text) & "CoreServices:Finder.app:Contents:Resources:Finder.icns"
set ptIconPath to (path to applications folder as text) & "Pro Tools.app:Contents:Resources:ProTools.icns"

if not osVersionCheck("10.12") then
	-- Display error message
	try
		activate application "Pro Tools"
		tell application "Pro Tools" to display dialog return & "This script requires macOS 10.12 or higher." & return with icon file finderIconPath buttons {"Cancel"} default button "Cancel"
	on error errorMessage number errorNumber
		if errorNumber = -1712 then -- If script times out
			return true
			
		else if errorNumber = -128 then -- If user cancels script
			return true
			
		else
			tell application "Pro Tools" to display alert "Error: " & the errorNumber & ": " message the errorMessage buttons {"OK"} default button "OK"
		end if
	end try
	
	activate application "Pro Tools"
	
else
	try
		if ptVersionCheck("12.8.2") then
			activate application "Pro Tools"
			tell application "System Events"
				tell process "Pro Tools"
					-- Check if an AudioSuite plug-in window is open
					if not (exists (every window whose name contains "Audio Suite")) then
						-- Do nothing
						
					else
						set asWindows to (get windows whose name contains "Audio Suite")
						repeat with aWindow in asWindows
							set windowName to name of aWindow
							set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ": "}
							set plugInName to text item 2 of windowName
							set AppleScript's text item delimiters to TID
							set buttonID to my identifierFor(plugInName)
							if buttonID is -1 then
								-- Display error message
								try
									tell application "Pro Tools"
										activate
										display alert "Plug-in " & plugInName & " not supported" message "Please, contact the author of this script." buttons {"OK"} default button "OK"
									end tell
								on error errorMessage number errorNumber
									if errorNumber = -1712 then -- If script times out
										return true
									end if
								end try
								
							else
								tell aWindow to click button buttonID
							end if
						end repeat
					end if
				end tell
			end tell
			
		else
			-- Display error message
			try
				tell application "Pro Tools"
					activate
					display alert "Incompatible Pro Tools Version" message "This action requires Pro Tools 12.8.2 or higher." buttons {"Cancel"} default button "Cancel"
				end tell
			on error errorMessage number errorNumber
				if errorNumber = -1712 then -- If script times out
					return true
				end if
			end try
		end if -- ptVersionCheck		
	end try
end if -- osVersionCheck

on ptVersionCheck(referenceVersion)
	set proToolsVersion to version of application "Pro Tools"
	considering numeric strings
		return (proToolsVersion as text) is greater than or equal to referenceVersion
	end considering
end ptVersionCheck

on osVersionCheck(referenceVersion)
	set osVersion to system version of (system info)
	considering numeric strings
		return (osVersion as text) is greater than or equal to referenceVersion
	end considering
end osVersionCheck

on identifierFor(buttonName)
	repeat with aRecord in buttonData
		if aRecord's name is buttonName then return aRecord's identifier
	end repeat
	return -1
end identifierFor

Download compiled script.
Reply With Quote