Activate Macro Group on Specific Google Chrome Websites

Hi,

I have a need to expand a typed snippet on a specific website in a Google Chrome web browser.

I was able to achieve that on JIRA website, which always has " - Issue Tracker" added to the frontmost window title. However, this doesn't work for Phabricator website which has radically different frontmost window title on each page.

Is it possible? For example, is there any way to obtain the URL of the currently opened tab (e.g. %ChromeURL% variable) and use it as a Macro Group activation condition?

Thank you.

Hi and welcome to the forum!

I would do this on a per-macro basis rather than activate groups or macros, simply because I'd prefer a macro didn't run on every window title change.

URL-Dependent Snippet.kmmacros (21 KB)

Macro screenshot

However, I can understand why you might prefer to do it the way you're suggesting. For one thing, setting up the snippet macros is a bit simpler, as you can use the trigger string auto-delete feature.

URL-Dependent Macro Enable-Disable .kmmacros (22 KB)

Macro screenshot

You can simplify this further to an If/Else rather than a Switch/Case if you want to enable/disable a group rather than individual macros. I just figured I'd cover as many options as possible; maybe you'd like some snippets only available on certain sites. Here, I've chosen to use matches for brevity, but you could equally use multiple if any conditions.

URL-Dependent Group Enable-Disable .kmmacros (21 KB)

Macro screenshot

1 Like

The last solution with a macro that conditionally deactivates/activates a macro group was the exact thing I had in mind, but due to limited Keyboard Maestro knowledge I didn't know where to start.

Thank you very much.

An interesting observation: a macro group deactivation is something different, than manually disabling it, because it still appears enabled (not greyed-out icon) in the Keyboard Maestro app, but doesn't work anymore.

Then it isn't working.

Demo Video

CleanShot 2022-09-02 at 14.06.55

One thing to point, out in case it isn't clear, is that the conditional matches are separated by the bar glyph (⇧\): |

What action are you using? Mine (see image) doesn't have "Enable" and "Disable" options. Instead, I use "Activate" and "Deactivate":

Enable/Disable Macro/Group

If you downloaded the macro I shared, it's in there.

I see now. Both ways (enable/disable, activate/deactivate) works.

1 Like

Here's a question relating to this.

Activating and deactivating macro groups based on the URL certainly works (thanks for the idea!), but it is rather awkward as the number of different websites in Chrome (just thinking about different Google apps alone!) proliferate. Since most websites are apps and not pages, it seems logical for KM users to have the equivalent of "Available in these applications:" for browser-based apps.

Is there a technical reason that prevents having Keyboard Maestro provide a filter in "Enable Macro Group" (akin to "Available when a focused window...") that is based on the URL? I realize this would be an enhancement to KM. Given how mature KM is, I'd assume it would already be supported it if were possible. If it is possible, this would enable all the power of macro groups to be accessible for browser-based apps.

Websites are not apps unless you wrap them as apps.

1 Like

Browsers don't pass the current URL back "up" to the OS, so it isn't easily available to KM -- you have to ask the browser for it (which is why the above works).

Luckily most web apps do have consistent page titling -- JIRA was mentioned in the OP, I've got a Group that's only active when our Freshdesk instance is the frontmost, etc -- that you can leverage with "Focused window title matches...".

2 Likes