Activate Main Web Browser (Different on Systems Where I Use the Same Set of Synced Macros)

Hi there,

I have a question regarding the activation of applications.

I use Keyboard Maestro for all my custom made shortcuts. I use quite a few and sync them across three machines. Now I want to use different main browsers on the systems which I want to activate with the same shortcut (for example cmd + 2 should open the main browser on all my systems which is Firefox on one system and Vivaldi browser on the others). I tried to use a symbolic link to achieve that, but keyboard maestro seems to follow the link on macro creation and uses the full path to the linked application when the macro is executed instead of using the symbolic link each time the macro is executed.

Does anybody have an idea on how to achieve it, to activate a different browser with the same shortcut on several synced machines?

Best regards,
Onliner

The AppleScript command

open location "<url>"

Will open the machine's default browser to the url.

ScottinPollock, thank you for your suggestion!

That would be a nice idea, but it would open a new tab each time. I realize that I have to add some more information to describe my use case better. I have the following settings associated with my shortcut:

19

I use it all the time, sometimes several times per minute, to switch between code editor, browser and terminal. So opening a new tab would be uncomfortable.

But thanks to your suggestion I got another idea. I will use apple script to open my symlink app. That would use the symlink on each macro activation and therefore survive the sync and work on my other machines as well. This is my solution:

activate application "/Applications/main_browser.app"

To make that macro work you have to create a symlink in the application directory to the application that you want to open with your terminal application:
ln -s /Applications/main_browser.app /Applications/Firefox.app

Thanks and best regards!

You could do it using this AppleScript:

use framework "Foundation"

property this : a reference to current application
property NSWorkspace : a reference to NSWorkspace of this
property NSURL : a reference to NSURL of this

set sharedWorkspace to NSWorkspace's sharedWorkspace()
set www to NSURL's URLWithString:"http:"
set AppPath to (sharedWorkspace's URLForApplicationToOpenURL:www) as text

activate the application named AppPath
2 Likes

That's a very clever AppleScript. Thanks for sharing.

1 Like

What about having a tiny URL file in your synced folder, and starting the macro by opening that file...which would then bring your preferred browser to the front?

Wow, that is awesome. Way less configuration without maintaining an extra symlink on each device. Thank you for this script! This one is in use from now on!

1 Like

You could also have the macro open location "<url>" then have the macro close that tab or window.