Holy cow, I wrote a book!
For quite some time, Windows has had a setting officially called active window tracking but which informally goes by the name X-Mouse, because that was the name of the PowerToy which first exposed the feature. (The PowerToy was in turn so-named because it made the mouse behave in a manner similar to many X window managers.) The setting is exposed to end users in Windows 7 on Make the mouse easier to use under Activate a window by hovering over it with the mouse.
If you want to write your own PowerToy to control this setting, you can do so by calling the SystemParametersInfo function. There are three settings which collectively control the X-Mouse feature:
SystemParametersInfo
SPI_SETACTIVEWINDOWTRACKING
SPI_SETACTIVEWNDTRKZORDER
SPI_SETACTIVEWNDTRKTIMEOUT
Note that X-Mouse is a user preference. Applications should not change the setting without the user's permission.