Text String Variable Task

Hey everyone,

I'm working on a project and I realized Keyboard Mastro would be a good fit for it.

I have a list of data formatted in a 4 letter sequence. (i.e 1A-2B-3C-4D, 1A-2A-3A-4A)
I'd like to set up a macro that can read the sequence and then react according to the order of the letter.

So for instance, if it reads 1A-2A-3A-4A
1A - Mouse click 989,1111
2A - Mouse click 989,511
3A - Mouse click 989,711
4A - Mouse click 989,811

Any thoughts on how I could approach this?

Screen Shot 2020-08-13 at 2.18.42 PM

To add a little more detail, I'm hoping to use the string matrix to trigger an event on the left most part of the screen.

Where is the text coming from?

Assuming you have the text in a variable called Source you can use:

Hi Peter,
Thanks for your help. The text is coming from an RTF document. Here's an image of how it's currently formatted.
Screen Shot 2020-08-15 at 9.26.43 PM
Would it be best to separate the values with commas/dashes?

Also, I've reviewed the approach you suggested & made a few attempts.
Attempt 1 Closest?.kmmacros|attachment (7.8 KB)
Attempt 2 (Not Sure).kmmacros|attachment (1.7 KB)

Would you mind sharing where they need to be altered? Thanks again.


Attempt 1 is close, and reading the file as done in Attempt 2 looks fine.


The search needs to be “matching” (matching = regex), and you need to search for \d\w.

And then you need to check the variable you are using in the For Each (S) in the Switch statement. You should have just one Switch action, testing variable S, and multiple entries.

Something like:

I am curious - any chance you could share at least in general terms what this software does?

Hey @rkaplan!

Generally Keyboard Maestro is an application that can help reduce the time one spends doing tedious tasks through the use of a wide variety of triggers. Think of it as a productivity tool. What I find makes it unique is just how modular, flexible & useful it is.

@peternlewis Thank you for developing it. It is extremely useful!

**@rkaplan I just noticed you've spent some time on the KM forum for a while. Were you asking specifically about my use case or what KM does? **

1 Like

Thanks for pointing that out. I've since made the revisions, but still can't get it to parse & execute actions. Mind sharing your thoughts once more?
For Each [Revised].kmmacros (3.8 KB)

The latter - I am totally a KM fan. I was just intrigued by your use case and am wondering what your codes/mouse clicks do.

1 Like

Oh, I see. I was exporting some tracks manually in Logic Pro & wanted to see how I could use a data matrix to automate the process.