I'm wondering if it's possible to do this with Keyboard Maestro and if so how to do it. I'm new to scripting and this has me stumped:
I'd like to have KM move the cursor to the right of a specific character in selected text. Precisely, I'd like to select some text in the iTunes Get Track Info window, and then trigger KM to move the cursor to the right of the first semi-colon in the selection.
What I don’t understand is how to do 2. and 3.? The position of the semicolon will be different depending on the text I will select (not always the same string, but always contains a semicolon where I need the cursor to be moved). How do I make KM calculate the position of the semicolon in a particular string?
I’m always amazed with the creativity people have on this forum. When I see potential solutions like yours, Chris, it just makes me smile. I never would have thought of your solution.
I need to remember to post more questions, to see if there’s better ways of doing things. In this forum, multiple heads truly are better than one.
@nadeama, I think this should do the job for you.
Please test the below macro, and let me know if it works for you.
Turns out that there is no easy way to find the position of a substring within a string using non-script KM Actions. So, I wrote a general purpose script to do this.
Thanks so much for your solutions. You guys are great!
Chris, your inventive solution worked like a charm in TextEdit, but as Michael pointed out it was problematic in iTunes (where I want to use it) because of the single-line fields of the Get Info dialog.
Michael, your script did the trick. You just saved me hours and hours of manual text input when editing tags in iTunes (I do a lot of that). Thank you!
Keyboard Maestro is really amazing. I can’t believe I haven’t used it before for anything but launching apps with a keystroke.
Nice, @ALYB. I got a little dizzy looking at your list of triggers, though, and wrote a different version that uses typed string trigger. You trigger it by typing two semi-colons and then the character in question, with no spaces, like so: ;;v, etc.
Yes, @cfriend I don’t like this long list of hotkeys either, and it costs a lot of hotkeys that are no longer available to other macros. Ideally I would press: one hotkey, character. But afaik this isn’t possible.
Hey Chris, I don't know if this belongs in a separate question or can just be added to this one.
I'm looking to move the cursor to immediately before the next open parenthesis and insert a couple of returns then immediately after a close parenthesis character and add another return. This moves the text within the parentheses along with the parenthesis onto their own line and out of the body of the text they are within so
Running the macro would then go to the next instance and pull out the text in parentheses along the enclosing parentheses.
FYI this is cleaning a large book worth text with loads these edits.
I think I can figure out how to get regex to find the characters I want but don't know how to use what regex finds to move the cursor to before or after the output.
The following should work. You can use a variable as your input instead of the sample text that I copied from your example. However if your text is inside a word processor with special formatting, this won't work. I couldn't tell if you were intending for this to work in a word processor or not. If so, the solution will be more complex.