Execute Series of Keystrokes Until the End of the Document

I'm trying to execute a sequence of keystrokes that repeat themselves until the end of the document (Pages) is reached by the macro. I place the cursor at the starting point and then execute the macro. I've managed to make one series of keystrokes to run correctly. Now the sequence should repeat itself until the end of the document is reached.The end of the document could be determined by the lack of a blank line (new paragraph).

Can someone please help?

(I think you would probably have to show us the macro, and a sample document, to concretise all that a bit, and allow for testing).

Hi! Sure thing. By the way, this is the step that precedes your Copy as chord macro. However, these are unrelated steps completely (i.e. require a separate macro).

Attached is the sample file and my macro. The macro applies different styles to the text, namely: chord name, chord graph, lyric. The text may end up in a chord graph or in a lyric style after the macro is sequentially executed. The macro should stop at the end of the document.

Style chord sheet.kmmacros (4.0 KB)
Style test.zip (51.2 KB)

Others will have much more experience than I do with GUI processes, and with Pages in particular.

On the scripting side, I wonder if any of this looks relevant ?

I wasn't aware of the unicode character set for these musical notations, excellent find, thanks! Will see if this can be integrated in my workflow, but I'd guess it's a simple matter of replacing the characters with the library.

That said, I hope someone with more experience with Gui processes can help. Maybe I need to insert a specific character at the end of the document and tell KM to stop at that.

Hi @Drukinn. I've assuming you started the key sequence you supplied with the cursor positioned on the line above the first chord. If not, I don't understand how you are attempting to change the format. If my assumption is incorrect, please supply a copy of the document with the desired changes applied.

But if my assumption is correct...

One possibility is to check the status of the Copy menu item. The following macro works for the example you supplied, but note the this would have to be modified if the format differs in any way. (Note that I changed the macro trigger; you'll might want to change that back.)

DOWNLOAD Macro File:
Style chord sheet (v2).kmmacros (16 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Image • Style chord sheet (v2)

Hi @_jims , I start the sequence at the end of the chord line. Then my macro executes a return and in the next line it styles for chord diagrams (F3). Then it moves to the line below and it styles for lyrics (F2). Then it moves the cursor to the end of the lyrics line. A final model can be seen attached. Your macro does not work for me.

Style test.zip (51.2 KB)

@Drukinn, thanks for supplying the document with the target format.

The following macro should do the trick. Position the cursor at the beginning of the first chord line before triggering the macro.

DOWNLOAD Macro File:
Style chord sheet (v3).kmmacros (16 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Image • Style chord sheet (v3)

1 Like

It works perfectly. Thank you so much @_jims !

2 Likes