Workflow to apply on a series of similiar macros

Hi,

I would like to activate the Solo Key of each audio track with one hot key in Avid Media Composer.

I created a macro uses the find image-action in a particular area since the position of the solo-button can change horizontal (depending whether there is a source clip in the window or not).

It works fine but I have to adjust it to every single one of my 20 audio tracks.

That means changing the Macro name (Solo A1, Solo A2,etc.) and modify the vertical distance to the same found image action:

A1 Just move 65 -365

A2 Just move 65 -345

A3 Just move 65 -325

A4 Just move 65 -305

The vertical position of my Audio tracks remain regular with a distance of 20 pixels each.

Is there a clever way to simplify that?

Cheers,

Simon

Move your macro actions to a Subroutine and then each of your 20 macros is just an Execute a Subroutine action.

If you want to be more clever, have the macro actions use the ExecutingThisMacro token, and use the Search using Regular Expression action ^A(\\d+) to extract the number after A at the start to a variable, and pass that to the subroutine, and have it use the Set Variable to Calculation action to calculate the offset (-385+20*Local Index). That way if the offsets change you can adjust the 20 in one place.

2 Likes

You could just start at {65, -365} from the found image then repeatedly click the mouse based on its current position:

Play with the "Pause" so it's long enough for a click to register (I assume that's what you're doing) but doesn't slow the macro too much -- err on the too long a Pause side.

One problem with that method is that and disturbance -- a knock of the mouse of a brush of the trackpad -- will upset things. It's more work to recalculate the click position each time, but will give a more robust macro:

1 Like

Hey Nige,

Thanks for getting back to me.
Not sure whether my post was clear enough. I would like to have 20 seperate macros under one hot key trigger to use the conflict palette but since those Macros just differ in the name and the vertical distance of the same found image I thought there might be an easier way to build those macros (maybe with a macro itself that builds them)

Thanks Peter,

Subroutines sound interesting but in my case will they really help me?

1 Like

Ah, gotcha.

In that case I'd go with @peternlewis's idea to use a subroutine. The sub would be something like:

Then your "Solo A1" macro would be

"Solo A2":

Using "Duplicate" and quickly editing the macro name and offset value it would only take a couple of minutes to do all 20 -- set the hot key on the first macro before starting the duplication!

But Peter then takes it a step further. Since your "trigger" macros are named "Solo An", where n is a number 1...20, your y offset for each will be -385 + (20 * n). Your sub then becomes:

...while your "triggers" are simply:

...duplicated and renamed.

It's quicker to make those "trigger" macros manually than to write an AppleScript to create them programmatically -- but scripting is more fun :wink: This script will create the macros "Solo A1" thru "Solo A20", all with an F1 hot key trigger (KeyCode of 122 in the script), in a Macro Group called "Import Solo Macros". Change the UUID in the first line to that of your subroutine:

AppleScript
set subUUID to "0422F017-4FDE-42A9-902C-3ECBCF77867A"

set preXML to "<dict>
	<key>Actions</key>
	<array>
		<dict>
			<key>ActionUID</key>
			<integer>101016240</integer>
			<key>MacroActionType</key>
			<string>ExecuteSubroutine</string>
			<key>MacroUID</key>
			<string>" & subUUID & "</string>
			<key>Parameters</key>
			<array>
				<string>%ExecutingThisMacro%</string>
			</array>
			<key>ResultVariable</key>
			<string></string>
			<key>TimeOutAbortsMacro</key>
			<true/>
		</dict>
	</array>
	<key>CreationDate</key>
	<real>803488254.11988795</real>
	<key>ModificationDate</key>
	<real>803489644.77099597</real>
	<key>Name</key>
	<string>Solo A"

set postXML to "</string>
	<key>Triggers</key>
	<array>
		<dict>
			<key>FireType</key>
			<string>Pressed</string>
			<key>KeyCode</key>
			<integer>122</integer>
			<key>MacroTriggerType</key>
			<string>HotKey</string>
			<key>Modifiers</key>
			<integer>0</integer>
		</dict>
	</array>
	<key>UID</key>
	<string>E7FEFB9B-21D7-4071-9BD2-7A15E1B12CC4</string>
</dict>"

set theXML to "<array><dict>
		<key>Activate</key>
		<string>Normal</string>
		<key>CreationDate</key>
		<real>803490439.01296306</real>
		<key>Macros</key>
		<array>
"

repeat with i from 1 to 20
	set theXML to theXML & preXML & i & postXML
end repeat

set theXML to theXML & "		</array>
		<key>Name</key>
		<string>Import Solo Macros</string>
		<key>ToggleMacroUID</key>
		<string>14217C37-9997-49BC-84D9-33CF6D9E820B</string>
		<key>UID</key>
		<string>93C41F89-6554-4634-8487-EAC754B34D1B</string>
	</dict>
	</array>"

tell application "Keyboard Maestro" to importMacros theXML
2 Likes

Wow, Gentlemen! What a lesson!
Thanks so much for your time and talent. That’s magic.

1 Like