I use Safari as my daily browser and have always preferred to avoid Google products.
I'm now engaged in some work where I need to collaborate with others using the full suite of Gmail, Drive and so on and I have decided to (kind of) sandbox all my Google activity in the Chrome browser, which allows me to keep Safari (kind of) clean.
Question is, how can I use KM to use Chrome when I have a Google link (e.g. Google calendar, or Google drive link that arrives by mail) and Safari if not?
I thought about using a Key Modifier when clicking a link, though I couldn't work something out to get that to work (WhileMail AND ctrl) and then I wondered if KM could change the Default browser for a moment before changing it back to Safari.
You have to place your Mouse pointer over the link and press the trigger hotkey. It will open the context menu, select Copy Link, then test the link for Google crap and open it with Chrome if necessary.
If you know beforehand which link is clean and which is Google you can of course omit the link test and send it directly to Chrome.
and then I wondered if KM could change the Default browser for a moment before changing it back to Safari.
This works fine for quickly switching back and forth between Safari and Chrome:
You should see this dialog then:
If you donât like the confirmation dialog you can automate the button press with KM actions (the non-default browser is always the right button):
[Edit:] @ccstone pointed out that for the Tab keystroke action to work you must have âAll controlsâ enabled in System Preferences > Keyboard > Shortcuts:
Bleep! I suspect you're right, and this is a âsecurityâ feature.
System Events can't press the button either.
But.
tell application "System Events"
tell application process "CoreServicesUIAgent"
tell window 1
tell button "Use âChromeâ"
action "AXPress" --> FAILS
set value of attribute "AXFocused" to true --> WORKS
end tell
end tell
end tell
end tell
From there you can use Keyboard Maestro to press the button.
tell application "System Events"
tell application process "CoreServicesUIAgent"
tell window 1
tell (first button whose name starts with "use")
set value of attribute "AXFocused" to true
end tell
end tell
end tell
end tell
that macro doesnât work anymore it seems or im doing something wrong.
I get the following error:
/var/folders/6m/yxr0h3nn2fl242hkgjy_jgb00000gn/T/Keyboard-Maestro-Script-57DD174B-8BA0-42DC-85EA-9589BB5DDFCC:2:33: error: cannot convert value of type âStringâ to expected argument type 'CFStringâ
LSSetDefaultHandlerForURLScheme(âhttpâ, âcom.google.Chromeâ)
^~~~~~
as CFString
I donât know what i can do to convert String to CFString. Is there anything im missing installation wise?
Donât know if youâve seen it, the other macro also has a hidden feature to show you all available http handlers. To see them you just have to run the action named âOr execute this script to get all âhttpâ apps on your Macâ. (Or alternatively enable the surrounding group and run the macro.)
See bottom of post #1 of the other thread.
The above looks terribly complex to me; I just want a hotkey, a macro, batchfile - whatever works - to QUICKLY change default browsers between Firefox and Edge. Which part of the above is relevant to my aim ?
Apple has not made this a simple task to script. While it's possible to do it with Keyboard Maestro running some Swift code, you have to contend with an intrusive dialog that asks you if you're sure you want to switch.