Hi,
I’m trying to use Window Focus Change to detect when a different Tab is selected in Firefox which in turn would trigger a macro which takes a certain action if the front window title contains certain words.
If I use a simple key combination to trigger the macro, the macro works fine. However, I was hoping to automate the procedure (getting lazy thanks to KM!). My problem is whereas Window Focus Change works reliably if a window changes (incl. dialog windows), that’s not the case when selecting Tabs because, presumably, the ‘window’ hasn’t changed, only the content.
I’ve found the same issue with other Tab-based applications e.g. Safari, Acrobat Reader DC (if the Tab layout option is selected). Needless to say, nothing changes in the app. Menu options, so I can’t point KM that way. Other than creating macros to manipulate Tabs (Previous Tab, Next Tab etc) and adding this macro to each one, does anyone have any other ideas?
Many thanks!
P.S. On the Tabs I want to run the macro on the title of the window doesn't change, so I can't use Front Window.Name to detect.
Hey Will,
I just tested on my system (Mojave) with Firefox 112.0.2, and the focussed-window Trigger works just fine when switching tabs (as long as they have different names).
-Chris
Display Text.kmmacros (2.5 KB)

Thanks Chris, thanks for your input and I can confirm. I’ve added the macro manually so to speak so it’s called whenever specified events happen e.g. the window name changes (provided the window name contains the organisation’s name which so far is always the case). Also whenever a different Tab is selected. For that I wrote several new macros which emulate Firefox’s built-in Tab navigation shortcuts and the call the target macro, so problem solved.
In cases where an app is changing the content of a window without changing it’s name I guess the only way KM could detect this would be to constantly take screen shots and compare them to the previous screen shot. No doubt such a function would present an unacceptable extra load on the KM engine. The existing functionality provided in KM could probably provide the user with ways to do this, but I think that too would have rather a high overhead!
Regards, Will
1 Like
Keep in mind that many more thinks are possible in web browsers that support AppleScript like Safari, Chromium, and others that are based on them.
With those browsers you can access web content with ease.
Thanks Chris, I'll bear that in mind. Do I gather from you comment that Firefox does not have extensive AppleScript support?
Firefox has the default AppleScript suite, and that will let you do a couple of things like move its windows around (not tabs).
It has NO Firefox-specific AppleScript suite, so you can't do anything at all Internet related.
And that means NO Keyboard Maestro integration.
Mozilla in their infinite wisdom dropped AppleScript support over a decade ago, and I quit using it (except for testing) at the same time.