Sometimes I run Safari, sometimes Brave, sometimes Firefox. Yeah, I have a problem. Any at rate, what I want to create is a macro that copies the URL from the active tab of the most recently active browser and pastes it in whatever text editor I am writing in at the moment.
So if I happen to have Safari open next to a text editor and am typing, a hotkey will grab the URL from there and paste it in where I am currently typing. If it is Brave, it will do the same. The extra tricky bit is sometimes I may have both Safari and Brave running, but I want it to be smart enough to copy the URL from the most recently active browser, which is likely to be the one I have next to the text editor and am copying from.
Of course I could make separate macros for each browser then give them the same hotkey so a palette pops up prompting me to pick the one I want. But if possible I'd like to make the macro smarter than that and automatically pick the most recently active browser. Can anyone suggest any ideas to do this?
I second TJ's idea of using one macro to track the last used browser in a variable, and using that variable in a separate macro used for pasting URLs. His suggested workflow should work fine for Firefox, but for Safari and Brave, KM's built-in %FrontBrowserURL% token simplifies and speeds things up considerably, letting you do something like this:
Thank you, both of you. Your workflows works perfectly. I appreciate the help.
One problem with using %FrontBrowserURL% for Safari is it no longer copies unicode, which is a nice feature Safari (and as far as I know, only Safari) supports. That is, if I copy a url that includes unicode in it (a url with Japanese characters, for example) it will paste the ascii code for that character instead of the character itself, whereas if I use the keystrokes method, it copy/pastes the unicode version. As result I am only using %FrontBrowserURL% for Brave, and using the keystroke method for Safari.
Incidentally, Gabe, it's good to see you here. I think we haven't talked in several years. Are you still kicking around Japan?