Trying to trigger a loop with clicks, once armed with toggle

Hi there,

I'm trying to find a way to 'arm' a macro– maybe via a status menu item, and then once armed, have an if-then statement trigger once per click, until disarmed.

Larger context: This macro helps me complete the final phase of my process for charting acoustic guitar songs– Placing each chord where it fits amongst the lyrics. The result of a previous macro is a Google Doc with lyrics and chords (extracted from a web search) formatted such that the chords and lyrics appear on alternating lines (the chords for a given set of lyrics being on the line above them).

What I'm going for is to be able to go through such a document, clicking where each next chord should go, placing them between lyrics.

So far what I have working is the part that belongs inside the if-then sequence– It goes to the line above, performs a regex search to grab the next chord and remove it, then pastes it.

What's not working is
– The click triggering the if-then sequence
– The location of the click being captured so that the chord can be pasted where the click was
Source material looks like:
image

Screenshots of version with attempted if-then and click portions disabled for testing of other parts:
![image|690x526](upload://subFg9ou3KW0zZ299bPJBpsx4Tn.jpeg


Screenshots of non-working version vaguely resembling what I'm imagining, with if-then enclosing the rest and clicking parts activated:



Any help is appreciated!

Hi @82Taylor,

This looks like a complex workflow, so it would help us help you a lot if you could upload the full macro (it's okay if it isn't currently working how you want), and provide some copy-and-pasteable sample text of both the source material and the target material (i.e. how the text looks before running the macro and how it should ideally look after). Instructions for uploading your macro can be found here if you're not sure how to do so: https://wiki.keyboardmaestro.com/Forum#How_to_PostUpload_Your_Macro_to_the_Forum

Also, you can copy your entire macro as an image from the Edit > Copy as menu, which nicely eliminates the need to stitch screenshots together.

1 Like

Hi gglick– Thank you, you're right this was much easier.
Song Chart: Place Chords Amongst Lyrics Macro (v9.0.5)

Song Chart- Place Chords Amongst Lyrics.kmmacros (6.9 KB)

Source Material:

C G AM
I may not always love you
EM EM7 A
but long as there are stars above you

Ideal state:

C I may not G always AM love you
EM but as long as there are EM7 stars A above you

Thank you, that made this much easier. I think this will do what you want, though in a different way than you had envisioned. Instead of recording the mouse position and copying the entire chord line every time you want to insert a new chord, this macro copies the chords above the current line, sets the chords to a variable, then inserts each chord in that variable every time the mouse is clicked, pausing until the click occurs:

Song Chart: Place Chords Amongst Lyrics 1.1.kmmacros (5.7 KB)

In Action

2 Likes

Thank you! I am kind of blown away by how helpful you are.

1 Like

@gglick is incredible! All he does is post solutions. He helped me with a macro so important that I sent him a check for 25K. Gabe sent the check to charity and added 50K because he is so awesome! :slight_smile:

1 Like