I'm not sure if I've got my head wrapped around this correctly or not but...
Using two apps called Metagrid and Plugsearch I created a number of MIDI CC triggers buttons on my iPad that open up plugin windows in Logic Pro. I probably created over 500 of these before I discovered KM and everything it is capable of just this last week. One of the first things I know I want to do is to have a macro that moves the plugin window once it has opened to the top of the screen. I've already create an action that does this well enough but adding a trigger for each of the 500+ MIDI CC I've all created seams pretty daunting. I don't want to have to repeat the task of adding each of the triggers and selecting "MIDI trigger" from the drop down list by hand.
I'm hoping to create a separate Hotkey Macro inside of KM that adds a new trigger to the current macro and selects MIDI Trigger from the drop down list to the plugin move macro I've created. I can't seem to find an appropriate action for this from the list though.
Is this even possible? If there are any other/easier methods for doing this I would love to hear your suggestions.
While you might be able to do this by scripting the Editor's interface, it's much easier to use AppleScript. To add a "blank" MIDI trigger to the currently-selected macro:
set theXML to "<dict>
<key>Channel</key>
<integer>0</integer>
<key>Device</key>
<string>Any MIDI Device</string>
<key>FireType</key>
<string>Pressed</string>
<key>Kind</key>
<string>Note</string>
<key>MacroTriggerType</key>
<string>MIDI</string>
<key>Note</key>
<integer>0</integer>
</dict>"
tell application "Keyboard Maestro"
set theMacro to item 1 of (get selectedMacros)
tell macro id theMacro
make new trigger with properties {xml:theXML}
end tell
end tell
...and you can see that most if it is the trigger template!
Here it is wrapped in a KM macro, with the XML separated out into a KM variable to make it easier to edit:
That would let you do one at a time, setting the trigger values (note, channel, etc) as you go. And it wouldn't take much to add a prompt that asked you for note, channel, and so on before building the XML.
That may be enough. But if you can make a list of macros and their associated trigger values you could do this in bulk.
Use macro UUIDs if you can, to avoid problems with duplicate names. I'd then build a comma-delimited list to pass to the AS:
macroUUID,fireType,channel,device,kind,note
...for the "note" trigger, but note that the "controller" and "packet" triggers have different options -- which is why I've put fireType "out of order" compared to the XML -- so it could get quite involved!
@Nige_S Thanks so much! The macro works great even though, I have to confess, I have almost no clue what I'm looking at.
The one other thing I'm hoping to achieve is to check the box "MIDI Learn (allow recording trigger)" of the most recent entry, and unchecked it from the previous entry. I realize the best way to learn this stuff a lot of the time is to figure it out on your own but if you know how to achieve this and don't mind sharing I would appreciate it
As far as the list goes I'm not sure I'm going to go that route but I've emailed the developer about it. The program allows for a .bin export of the data but I'm again as an amateur, I'm not sure what to do with this, other than keep it as a backup to import into the program
Is this needed? Not a MIDI user but, as I understand it, "MIDI Learn" only happens when one of that trigger's text fields has focus -- so the only reason to turn it off for "earlier" triggers is so that you can't activate one of their text fields then accidentally hit a MIDI key.
If you do need to do it, I can't see a way via XML or AppleScript -- I think you are reduced to manipulating the UI. One method would be to use image detection, uncheck every item that is checked, then check only the bottom one:
You should swap the images in that for your own screenshots. I've left a "Pause" in so you can see what's happening, you can remove it (or reduce it as much as your machine will allow before the macro breaks) once you're happy.
@Nige_S The click at found image is working just fine for this action and I didn't realize but when the Macro is executed the previous checkbox was automatically unchecked so it was a simple point and click process.
The only thing I'm having issue with now is that the macro creates a Note trigger instead of a Controller trigger. I'm such a noob I can't even figure out how to change this in variable statement. I even asked chatGPT and Gemini how to mend it but, as expected, neither were able to fix it. I'm incredibly grateful for the time you've taken on this issue already and if you don't feel like spending anymore time on this issue I completely understand but if you did let me know how I could amend it I would be very appreciative.
It's worth doing it yourself so you can see how easy it is.
Make a new macro -- don't add any actions
Set the trigger to be your MIDI trigger
Set the trigger options to those you want to create with the macro
From the "Edit" menu select "Copy as" then "Copy as XML"
Switch to your favourite text editor (TextEdit is fine), make a new document, "Paste"
There's your macro! If you look down the text you'll see (around line 30):
<key>Triggers</key>
...
...which is the start of the triggers "block". Triggers are held in an array (list) so you can have more than one per macro, and each trigger is contained within its own dictionary:
...and since we've only one trigger there's only one dictionary.
It's that dictionary we are using to set the properties of the new trigger. Replace the text in the "Add a MIDI Trigger" macro's first action with the dictionary block from your text file and you are good to go.
You can use the same process to add any trigger you want -- set up the trigger, copy the relevant part of the XML, use it as your template in the macro. KM takes care of the rest.