First time poster, novice/intermediate KM user. I was just so excited about this one I had to share it :)
Unfortunately Keyboard Maestro can't control Firefox in the same way as it does Chrome or Safari, because Firefox doesn't speak AppleScript.
This post shares a workaround which allows me to instantly open a particular URL in Firefox, from typed input or a clipboard.
I use it as a standalone macro, but it might work well as a subroutine too.
The most obvious and simple way to open a URL in Firefox would be a UI script for something like
- get URL from user input or clipboard
- activate Firefox
- Cmd+T
- Cmd+V
- Return / Enter
Unfortunately, I am not a patient woman, and sometimes the "Activate Firefox" action takes a few seconds to actually happen. And then every now and then Firefox throws a tantrum and relaunches in safe mode, like it's offended at being launched by a macro. Come on! All I want is for everything to work instantly every single time – is that so much to ask??
So I came up with something that goes:
[ trigger macro + type URL + Enter = Firefox loads typed URL ], or
[ trigger macro = Firefox loads URL from clipboard ]
And it's hella quick. It goes like this:
- get the specified URL (encoded as "%Variable%url%") from user input
- check if %Variable%url% already contains "http://" or "https://"
- create a .url file in a specified disk location which points to the correct URL, including "https://" if needed
- use Firefox (or any other browser) to open the .url file
- delete .url file
The clipboard version works the same, except %Variable%url% is replaced with %SystemClipboard%.
What I've uploaded contains some extra actions and a "container macro", which combine to let me use the same hotkey (Alt + Space) with a single or double press to trigger the macro: single press = user input, double press = cancel macro for user input and load url from clipboard.
If you prefer distinct triggers, disable or remove everything coloured in Teal, set your own triggers and it should all still work well.
FIREFOX_GO-TO-URL.kmmacros (15.4 KB)
• • •
Extra notes:
-
Duplicating and modifying the stock Search the Web macro was the first thing I tried, but half the time Firefox would launch with only a blank new tab. infuriating! and even when it worked, it was slow.
-
you'll have to add some extra exceptions / checks if you want to use this for anything outside of http / https, eg. your local network portal
-
the action which deletes the .url file is not strictly necessary, because the file is rewritten every time you run one of the macros
-
I'm using Keyboard Maestro 11.0.3. It's December, 2024.