I wrote the highly sophisticated macro below which opens all the links in an email within highlighted text, even if the links are nested within text.
I find it very convenient. It's for sale, order today before midnight and get 50% off !
No seriously, it works in Mail and also in many other apps, like Pages and other document formats.
Is there any way to make the macro app independent, so that it works anytime the services menu contain Open URL ?
Note that the text display should read: highlight text containing links.
Thanks in advance for your time and help.
Make the macro global in scope.
Change the app to the front application and the menu title to APPLICATION.
Thank you for your post.
- I put the macro in the global macro group, always active, all apps
- i edited the macro → Formost Application
it does not work. I wonder if there could be a step missing (red arrow)
Yes, there is. See how the Menu Title field was "Mail" in the original macro? You need to use
APPLICATION when selecting a menu in the front application with this action:
Incidentally, is there a particular reason you're using a service for this? If you're already highlighting the text containing the links anyway, I might consider making a macro that copies the text to the clipboard and opens each link like this:
Open All Links in Selected Text.kmmacros (2.8 KB)
works beautifully, and in the background. Fantastic !
thank you so much
@gglick, nice solution!
But I have to say, that is one whale of a RegEx:
It seems to work fine in KM, but Regex101.com chokes on it, saying it doesn't like all of the
\u metacharacters. I have no idea why.
I don't know if there is much of a speed penalty for a long RegEx like that, but I did find this one on stackoverflow.com that is much simpler, and seems to work in my testing:
Thanks, @JMichaelTX! I found that regex on StackOverflow too, but went with this one on GitHub mainly because it seemed like it would cover more edge cases. I know it's a lot longer and more complex, but in practice the speed difference seems negligible, so as long as it works in KM, I figured I might as well go with it. Still, as they say, there's almost always more than one way to handle things like this, especially when it comes to regex, so having more options to choose from absolutely can't hurt
Thank you for all your research
I am creating a Services menu palette which works globally (not app specific). I reviewed your post above don't understand why this action does not work.
I tried Menu Title both Application and APPLICATION (like in your example), and I tried inverting menu item and submenu, but nothing works
If I replace Menu Title Application with the name of the application (example: Chrome), it works fine, so the problem seems to be with what I should write for Menu Title.
thanks very much !
APPLICATION in all caps with Services as the submenu:
works for me in several apps I tested except for Chrome/Brave Browser, so I think the problem is most likely specific to Chrome. Given that, the way I'd get around this is to use a Switch/Case so that Chrome uses a specific action and every other app uses the generic APPLICATION:
Switch:Case.kmactions (1.7 KB)
great solution ! very smart. thanks very much !
WOW ! I downloaded and ran the .kmactions files to insert the macro. Very impressive. Had never seen that.
Heh, yes, that's what happens when you only export actions rather than a full macro. Usually the full macro is the way to go, but as you've seen, sometimes all you need is the actions (though of course, if you don't know in advance that .kmactions files open in the macro currently being edited, it can lead to a bit of confusion at first).