Hi, I am looking for a macro which activates the application of the window below the current mouse position. What I could not find is how do I get the application name once I get the %WindowFrame%1% value (it gives the frame of the front window). Can you help me?
cheers
--e.
I normally do this by using the Move or Click Mouse action to click the mouse at its current location. That then activates the app under the mouse and brings it to the front.
Would that do what you want?
If you have a really old version of macOS, this might work, if you type it in a Terminal window:
defaults write com.apple.Terminal FocusFollowsMouse -bool true
But if you have a current version of macOS, installing this may work: (there are several apps that claim to do what you want, but this one seems to be free and reliable. I suspect that they use undocumented APIs, which is why KM cannot do it.)
GitHub - sbmpost/AutoRaise: AutoRaise (and focus) a window when hovering over it with the mouse
I need to point out that there is a difference between switching the focus and raising the window. If you click on a window with CTRL+OPT+Click, the window that the mouse is currently over will become FOCUSSED but the windows will remain where they are. (WARNING: this works 100% of the time half the time, and 0% of the time the other half. I have no idea why. There may be some context that I don't yet understand.) This may be sufficient for your needs, as all the keyboard shortcuts will be activated for the new focussed app, even if the window is not frontmost.
Thanks @tiffle, that’s what I’m doing now, but: clicking may be dangerous since by chance there could be a button there, while just moving does not activate…
Correct, but CTRL-OPT+Click does not actually click in the app, it just focusses the app.
CTRL-OPT+Click made it! Very nice advise, thanks!
Once in a while I come up with a good answer.
Curiously, if you press it twice, it does something different. I.e., the second time you press it (if the window is not already frontmost) it activates the window and brings up the context sensitive menu at the current mouse location.
Even more curiously, if you double click, rather than press it twice in a row (but not fast enough to constitute a double click) it does something slightly different, at least for some apps. I'm not sure what it's doing there.
The 'control+click' still goes through, and right clicks on the element of the app out of focus while bringing it into focus, most cases this just brings up a context menu (annoying) but depending on the app could do something destructive.
Also, TIL that Option+Click on an out of focus app always HIDES the previously focused app... Who would have thought?
This command only makes focus follow mouse for Terminal windows—that's the domain in the first part of the command, com.apple.Terminal
.
But if you use Terminal a lot and would like focus to follow the mouse, the good news is the command very much still works in the current release of macOS. But it won't have any effect on any other app.
-rob.
Oh, thanks! Well, that's not bad, especially if you can list other apps besides Terminal. To me, that's a valid solution, even though you have to name the apps.
Sorry I wasn't clear enough: That is not a general setting, it's a setting specific to Terminal. Terminal has the code in it to look for that value to be set, and to behave accordingly. Listing any other app will have zero effect, because they're not coded to support focus follows mouse. The setting is exclusive to Terminal.
More than likely, Terminal has such code because it's likely to be used by those coming from Linux, where focus follows mouse is a thing that many people are used to. But that's just a guess.
-rob.
Oh. Ok. Thanks, sorry.