MACRO: Capture and work with multiple text selections in one pass

This macro demonstrates a method to easily capture multiple selected text strings in one run of the macro. After activating the macro (Shift-Control-Option-5), each selection of text is copied to the clipboard, where each selection can be processed individually.

When the macro is cancelled (by pressing the Control key), a post-processing loop takes over, where the entire group of selections can be processed by further actions. The demo macro does just two things: It builds a long text string with a counter showing the number of each selection, and it builds a Dictionary, where each selection is one entry in the Dictionary (the Dictionary is deleted at the end, so as to not clutter your Dictionaries).

Here's how it looks in action (greatly sped up), showing the selection of multiple lines of text, followed by the display of the text string built from those selections:

An animated GIF resides within

selector9

And here's the macro…

Download Macro(s): The Unlimited Selector.kmmacros (22 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.5
  • Keyboard Maestro v11.0.3

I honestly have no idea if this idea is directly useful to anyone, but I like how easy it makes it to collect and manage any number of text selections.

-rob.

3 Likes

Nice! The macro as a whole, and some of the components, too.

Thanks for sharing.

@griffman sorry for the beginner question...but what if I wanted to select multiple lines of text simultaneously (e.g., if I copy multiple rows in a Google sheet column) and then want to work with individual lines, either by 1) pasting subsequent lines every time CMD+V is pressed or 2) pasting specific line numbers based on their index position in the column?

In my use case, I have a table of fields to populate with text in a different application. The UI presents a table, but not as a spreadsheet - each cell is its own text entry field. As a result, all pasted data is confined to the selected cell, not distributed down the column or across a row (like what would happen in pasting into another Google sheet).

I've been playing around with different loops, trying to trim the white space and then invoke the Lines counter function to delineate and parse lines for single-line extraction, but I can't seem to figure it out. I've also tried adjusting existing, seemingly similar macros from the KM forums, but I'm still having trouble.

I'd sincerely appreciate help!

You should be able to just copy your selection, then use a loop like this:

Then do whatever you need to do to each line—if it's just paste them one by one, then you can just send the Command-V keystroke. Pasting specific line numbers will be more complicated, and we'd need some specific examples of what you're trying to do. If that's the need, I recommend opening a new topic asking for help with that scenario.

-rob.

1 Like