I started using Windows 7 only because my Windows XP machine's harddisk was failing on me. My new machine came with Windows 7 installed. After some tweaking the settings I could not find a way to enable the Focus-Follow-Mouse-Without-Raising-Windows behaviour I was used to. On Windows XP I used Tweak UI to enable this, but that doesnot exist for Windows 7. Turned out the following C# Console Application does the trick!
For more info look at the SystemParametersInfo function documentation at MSDN.
using System.Runtime.InteropServices;
namespace SPI
{
class Program
{
[DllImport("user32", CharSet = CharSet.Auto)]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, bool pvParam, uint fuWinIni);
/// Determines whether active window tracking (activating the window the mouse is on) is on or off. The pvParam parameter must point
/// to a BOOL variable that receives TRUE for on, or FALSE for off.
/// Windows NT, Windows 95: This value is not supported.
public const uint SPI_GETACTIVEWINDOWTRACKING = 0x1000;
/// Sets active window tracking (activating the window the mouse is on) either on or off. Set pvParam to TRUE for on or FALSE for off.
/// Windows NT, Windows 95: This value is not supported.
public const uint SPI_SETACTIVEWINDOWTRACKING = 0x1001;
/// Determines whether windows activated through active window tracking will be brought to the top. The pvParam parameter must point
/// to a BOOL variable that receives TRUE for on, or FALSE for off.
/// Windows NT, Windows 95: This value is not supported.
public const uint SPI_GETACTIVEWNDTRKZORDER = 0x100C;
/// Determines whether or not windows activated through active window tracking should be brought to the top. Set pvParam to TRUE
/// for on or FALSE for off.
/// Windows NT, Windows 95: This value is not supported.
public const uint SPI_SETACTIVEWNDTRKZORDER = 0x100D;
static void Main(string[] args)
{
// set mouse to x-mouse behaviour, focus on window under mouse without raising the window to top
bool enable = true;
bool disable = false;
SystemParametersInfo(SPI_SETACTIVEWINDOWTRACKING, 0, enable, 0);
SystemParametersInfo(SPI_SETACTIVEWNDTRKZORDER, 0, disable, 0);
}
}
}
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Tuesday, October 29, 2013
Subscribe to:
Posts (Atom)