Using named clipboards in Ableton to automatically switch presets on keyboard


My MIDI controller broke, so I need to use another where I have to do program changes to load up presets I've made to control various instruments in Ableton.

I want to trigger these program changes automatically on my controller while I scroll. So far I've been able to make that happen according to what image is on screen in a certain area, with a blurry version of the image it's looking for, so it's really reacting to a big block of colour (my instrument groups are colour coded) for each program change. This makes it change programs automatically while I scroll through the session, however, it means I can't sustain notes when I want to play because the program change is constantly being triggered by the image on screen.

What I'd like:
to make it work by screen capturing that area of the screen to clipboard "Temporary", converting the image on "Temporary" to text using "OCR Image on Clipboard "Temporary" and pasting that text to clipboard Temporary 2. Then trigger the program change with If/Then, if any of that text matches text in a list that I've defined (defined as that same text it's converting, per instrument group). So I'll have a separate If/Then for each instrument group.

I've gotten everything to work except actually making the program changes using the extracted text. I've tried: If clipboard "Temporary 2" contains: (the text it extracts for each instrument group) but that doesn't work because it appears to be looking at the text I write int he box as an entire string that it's comparing it to. I've also tried: If clipboard "Temporary 2" contains "Variable" where I've made a variable for each instrument group, and entered the text it's extracting as it's own item, separated by commas, but I'm clearly not understanding how variables work.

Note: it doesn't bother me that the text being captured and pasted into Temporary 2 doesn't always match what's on screen because it's always consistently the same which is all that really matters.

Photo of my macro:

My second question is: having KM screen capture every second isn't going to eat up space on my computer right? Each screen cap just replaces the last one?

Thanks in advance for any help you guys can offer!
SL MKIII Periodic Program Change Trigger.kmmacros (60.1 KB)

@samuelpksmith Have you looked into Automap? You may not need KM for this at all.

Hey @noisneil, I don't think automap will work for this particular issue unfortunately as I'm not actually trying to control effects devices in Ableton. I'm using KM to send program changes to my actual controller (rather than from the controller to Ableton), which already requires a MIDI translator. I'm using Orchestral Tools Berlin series of instruments for a film score at the moment, and each instance (longs/shorts, trem/trill etc) have different key mappings to bring up various articulations, and they change from instrument to instrument. I've gone into Components (the extremely awful novation controller customising app) and created a template for each instrument with the articulations mapped to the pads on my SL MKIII, and each of those instruments is in a "session" (which is actually supposed to be used for sequencing and doesn't actually receive regular MIDI data) which acts as my instrument group. I had to get a MIDI translator to actually be able to trigger individual sessions in the first place which was a whole other bag of worms).

Each instrument in the controller bank is selectable and record enable-able in Ableton (from my controller) once the bank comes up , but each instrument (in Orchestral Tools) doesn't necessarily have the same articulations or even the same number of articulations. Hence why I want KM to automatically trigger the program changes as I scroll around. That way I can play whichever instrument in whichever group without having to click anywhere or press any hotkeys.

I thought this was what Automap did...? From the Novation website:

"Automap is a piece of software that comes with all Novation controllers. It has been designed to make the job of assigning your hardware controls to various software parameters quick and easy."

I must have misunderstood. I thought you wanted to change the controller assignments when you switched track.

Haha, yes that would be a lot easier! Unfortunately it's not what I need. I've only been using keyboard maestro a short time, but it seems like an extremely capable program. Surely there's a way to make it trigger if any single word in a list of words appears on my Temporary 2 clipboard?

By "scroll", do you mean change track selection? If do, do you tend do this only with the up/down arrows or do you click with the mouse too? I'm trying to determine whether a repeated 1sec trigger is the best idea.

How are you triggering this method? Is it the 1sec repeat? We might be able to make only actually do anything when the image first changes, so it's not constantly interrupting sustained notes.

This can be done in one move using the OCR Screen action and choosing an area.

No, what you'd want here is a Switch/Case group. It's like an If/Then but with multiple conditions.

What are the screenshots of? All track header boxes at once?


CleanShot 2022-07-01 at 02.07.56

Surely if you're trying to determine what track you're currently on, you'd want to use this box, like in the other thing you posted about recently...?


CleanShot 2022-07-01 at 02.10.01

Otherwise the OCR result will contain the names of tracks other than the one you're interested in at the current time and muddle things.

Not space, no, but it will incur a processor overhead. Whether it's tolerable will depend on how hard you're pushing your system with other processes. This is why it would be great to find another method of triggering the macro.

Just one last thought... Maybe you should ask around on this forum to see if it's possible to use scripting to achieve this...? It seems like getting the current track name might be something people over there know how to do.

I mean scroll with the mouse wheel up and down my session.

Yeah this is with the 1 sec repeat. And it does work except for the fact it's triggering every second :sweat_smile: Using the OCR to Temporary 2 action seems like a better route as the text doesn't constantly update, so the program change on the controller isn't constantly being triggered every second.

Using OCR to determine the text in that specific area didn't work (maybe there's not enough contrast between the text and background colour)? It came up with an error message about not enough DPI, switching to 70 - something along those lines... Also, having the names of multiple tracks in the clipboard is actually preferable, as it's just triggering a program change to a setting on my controller which has every instrument in those groups loaded up for me to select on my own. I don't necessarily need it to read just one track name.

I've gotten it to work using the If/Then (before you mentioned the switch/case action) using the following, but surely there is a way to just write items in a list of some kind rather than having to make a separate condition for each track name?

This actually seemed to come up with less consistent results than OCR Image did for some reason (I thought it's supposed to be more accurate?). Thanks for the Javascript suggestion. I have absolutely zero knowledge about Javascript, but I've gone on to that forum and asked about this idea. Seems like the track names would actually be accurate that way at least!

KM has a shortcut for "some text contains 'this' OR 'that' OR..." -- you use "matches" instead of "contains" and you separate your terms with pipe (|) character:

...would match "Trumpet 1" or "Trumpet 2" (or both).

You can also use regular expression matching.

Best thing to do is write a list of all the things you want to "detect" on the clipboard and the actions you want to take with each "set" -- I'm sure someone will come up with a neat way of doing things!

So you're just changing what's visible, not which track is selected...? Sounds like a lot of moving parts to me.

If you managed to get it working but you want it to trigger only when needed, why not trigger it manually? I can imagine you'd quickly get into the habit of tapping a hotkey to refresh your controller state. Perhaps there's a seldom-used button on the controller itself that you could use as a midi trigger...?

Have you tried calling Monterey's OCR capabilities from KM? Slightly less zippy than KM's native OCR but tons more accurate.


KM Actions

Your screenshot it still using an If/Else. Look for the Switch/Case action.


Surely there's more than one configuration where the screen would display, for example, "Trumpet 1"? Perhaps I still don't get it, but it seems like there would be multiple matches unless you were very specific about the track height and what was displayed onscreen at a given time... and triggered the macro manually.

@noisneil @Nige_S I actually found a way simpler way to do what I wanted to do in the end. I ended up using Control Surface Studio and made it so that every time I select a track of a certain colour it triggers the program change to the correct Session bank on my controller. Thanks so much for your input and help though - I really appreciate it!

1 Like