Focus Follows Mouse System wide

Greetings,

I've been using Terminal Focus follows mouse and its been awesome, but i started working a program that would enable this feature on all the Windows, im stuck on a getting window information under a cursor, is there an api or am i thinking it all wrong. Thank you

Well, +[NSWindow windowNumberAtPoint:belowWindowWithWindowNumber:] sort of does this. The problem is that it gives you a window number and there are few APIs that let you do something meaningful with a window number, especially for windows not owned by the calling app. There's also the CGWindowList API (a.k.a. Quartz Window Services). It can return information about windows, including a window number. To my knowledge, there's no documented correspondence between these two notions of window number, but they are the same.


CGWindowList can also provide the process ID of the process which owns the window. You can use that to activate the owning app. However, you can't easily put focus on a specific window within the app.


The other API to investigate is the Accessiblity API. That's designed for assistive devices and software, and focus follows mouse could be thought of as an assistive feature of sorts.

ive looked at

[NSWindow windowNumberAtPoint:belowWindowWithWindowNumber:]

and the problem is you have to click the window:

Returns the number of the frontmost window that would be hit by a mouse-down at the specified screen location.

i also messed with CGWindowList API and there is a lot of stuff, but its not feasible atm. seems like it wont be that easy to make this work with out pure cocoa. :/

Focus Follows Mouse System wide
 
 
Q