81

I'd like raise-on-click and sloppy focus-follows-mouse on Windows 10 because this is the setup I've been using on Windows and Linux for years.

Under Windows 10, I tried the regedit Xmouse changes mentioned in this link that were originally meant for Windows 8: http://winaero.com/blog/turn-on-xmouse-active-window-tracking-focus-follows-mouse-pointer-feature-in-windows-8-1-windows-8-and-windows-7/

However, I experienced the following issues:

  1. When you open the Start Menu by pressing the Windows key, it doesn't receive keyboard input.

  2. When you open Start, Search or Notifications by clicking on them, they close before you can interact with them.

Is there anyway to get usable focus follows mouse?

Is anyone successfully using Win10 like this?

2
  • 1
    A workaround for issue #1 is to click the magnifying glass (search) instead. The shortcut key for this is Window + S.
    – andz
    Aug 11, 2015 at 18:33
  • 1
    You might be able to avoid Issue #2 by setting ActiveWndTrkTimeout to a higher value. WinAero Xmouse Tuner used to have a minimum of 500ms, but it is now lowered to a minimum of 100ms in WinAero Tweaker due to overwhelming requests. It is still not possible to lower it to below 100ms but there might be a good reason for that.
    – andz
    Aug 11, 2015 at 18:33

10 Answers 10

58

Use X-Mouse Controls (Wayback Machine link), it's the closest I've found to true Focus Follows Mouse, and it has some options to tweak. It's a small open-source utility that doesn't require installing or rebooting, and saves you from changing the registry yourself.

As far as I've experimented, I can use the keyboard to search for files/programs after pressing the Win key. Also, Start and Notifications menu don't go away before I can use them, even with the raise-on-hover option, as you can set a small delay for the behavior (one or two hundred ms will suffice), which gives you more than enough room to move the pointer to the new window.

I've used it for a while and I'm quite happy with it, plus the bug.n tiling window manager. This setup is as close as I've been to using dwm on unix.

1
  • this worked well for me. Download the zip file, unzip it, execute X-Mouse Controls.exe, choose options in the dialog window, press 'Apply', that's it! You can change the various options to try them out. This helped me because long ago I had configured Windows to automatically raise windows when the cursor hovers over them. This gradually became annoying and confusing but I couldn't remember how I'd done it.
    – Kai Carver
    Apr 9 at 8:29
35

The following powershell script should have the same effect as the XMouse program... without having to execute a 3rd party binary

Code:

$signature = @"
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(int uAction, int uParam, ref 
int lpvParam, int flags );
"@

$systemParamInfo = Add-Type -memberDefinition  $signature -Name SloppyFocusMouse -passThru

[Int32]$newVal = 1
$systemParamInfo::SystemParametersInfo(0x1001, 0, [REF]$newVal, 2)

Constants retrieved from here

4
  • That works beautifully, better than anything else I've tried. Just save this in a .ps1 file, right-click it and choose Run with Powershell. You can even add it in Task Scheduler to start at boot.
    – Zurd
    Jan 22, 2018 at 17:36
  • 1
    To eliminate the default 500ms delay, I used regedit to change HKEY_CURRENT_USER\Control Panel\Desktop 's ActiveWndTrkTimeout to 0. Requires you to log out and back in. Feb 6, 2020 at 0:17
  • For a permanent SloppyFocusMouse, I changed Computer\HKEY_CURRENT_USER\Control Panel\Desktop 's UserPreferenceMask's first hex data from "9e" to "9f" Feb 6, 2020 at 0:19
  • 1
    I used this but found it a one-way street and so installed XMouse to disable it :) Changing $newVal = 0 did not put it back to normal, which is odd. Perhaps if I'd done a restart it would have reverted, although enabling it was instant.
    – noelicus
    Mar 25, 2020 at 9:45
18

The registry modifications mentioned in the question's link do work on Windows 10. However, it seems they have to be made when the option “Activate a window by hovering over it with the mouse” is selected in the accessibility settings. This option can be found under Control Panel > Ease of Access > Change How Your Mouse Works.

This option also makes windows auto-raise, but the registry modifications stop this behaviour.

If you are experiencing the same issues and the checkbox is selected, unselect it, click apply, select it again and redo the modifications. The mouse should behave properly the next time you log in.

1
  • 4
    However, that does what the name suggests - raises the windows automatically. OP wants it to NOT raise, but still allow focus on a background window. Following the Q's Winaero instructions (setting first hex code to 9F) and logging in and out seems to be working okay. Win key + typing = works for search. Win button with mouse + typing = does NOT work for search if focus is ever away from said button, but does if I keep the mouse hovering over the button. Killing explorer.exe and running userinit.exe did not work to load the reg settings, so logoff seems needed.
    – mpag
    Sep 8, 2017 at 18:00
13

Windows actually has a flag to enable focus-follows-mouse ("active window tracking"), which can be enabled easily via the monstrous "SystemParametersInfo" Win32 API call. There are third-party programs to enable the flag, such as X-Mouse Controls, or you can perform the call directly using PowerShell.

The documentation isn't always super clear on how the pvParam argument is used, and some powershell snippets incorrectly pass a pointer to the value, rather than the value itself, when setting this particular flag. This ends up always being interpreted as true, i.e. they accidently work for enabling the flag, but not for disabling it again.

Below is a powershell snippet that performs the call correctly. It also includes proper error-checking, and I've tried to go for cleanliness rather than brevity, to also make it easier to add wrappers for other functionality of SystemParametersInfo, should you find some that interests you.

Shout-out to pinvoke.net for being a helpful resource for stuff like this.

Add-Type -TypeDefinition @'
    using System;
    using System.Runtime.InteropServices;
    using System.ComponentModel;

    public static class Spi {
        [System.FlagsAttribute]
        private enum Flags : uint {
            None            = 0x0,
            UpdateIniFile   = 0x1,
            SendChange      = 0x2,
        }

        [DllImport("user32.dll", SetLastError = true)]
        private static extern bool SystemParametersInfo(
            uint uiAction, uint uiParam, UIntPtr pvParam, Flags flags );

        [DllImport("user32.dll", SetLastError = true)]
        private static extern bool SystemParametersInfo(
            uint uiAction, uint uiParam, out bool pvParam, Flags flags );

        private static void check( bool ok ) {
            if( ! ok )
                throw new Win32Exception( Marshal.GetLastWin32Error() );
        }

        private static UIntPtr ToUIntPtr( this bool value ) {
            return new UIntPtr( value ? 1u : 0u );
        }

        public static bool GetActiveWindowTracking() {
            bool enabled;
            check( SystemParametersInfo( 0x1000, 0, out enabled, Flags.None ) );
            return enabled;
        }

        public static void SetActiveWindowTracking( bool enabled ) {
            // note: pvParam contains the boolean (cast to void*), not a pointer to it!
            check( SystemParametersInfo( 0x1001, 0, enabled.ToUIntPtr(), Flags.SendChange ) );
        }
    }
'@

# check if mouse-focus is enabled
[Spi]::GetActiveWindowTracking()

# disable mouse-focus (default)
[Spi]::SetActiveWindowTracking( $false )

# enable mouse-focus
[Spi]::SetActiveWindowTracking( $true )
7
  • 2
    Hello, wellcome to superuser. Please, when you make new contributions, try to give some explanations attached to your code. Although your answer seems correct, it would be better if you explained WHY it works, so if someone wants to make something slightly different they can get an starting point on your answer. Anyway, thank you for sharing your knoweldge with us!
    – DGoiko
    May 13, 2019 at 19:26
  • 1
    There, I've fleshed out the explanation.
    – Matthijs
    May 14, 2019 at 21:26
  • 1
    Great! I'm glad to be your first upvote, hope a lot more will come :D
    – DGoiko
    May 14, 2019 at 21:41
  • I thought this was a nice solution and enabled it, but it caused some undesired side effects with pop-ups (Windows UI, Outlook), so I had to disable it. In Linux Mint Cinnamon, there's an option for "focus on mouse hover", even bringing the whole window to the foreground.
    – winkmal
    Feb 4, 2021 at 10:20
  • @rotton raise and focus are different things, and the whole point for focus-follows-mouse is to be able to focus windows without being forced to raise them. what you're describing (raising a window when hovering over it with some delay) sounds extremely annoying to me, but is presumably meant as an accessibility feature for people with limited hand functionality
    – Matthijs
    Feb 5, 2021 at 11:06
2

For those who couldn't get it to work by just subtracting 40 from the first byte of UserPreferencesMask, just get the WinAero Tweaker utility itself at http://winaero.com/download.php?view.1796

Note that issue #1 above is still present, but easily worked around by just using the magnifying glass (search) icon to the right of the start menu (shortcut key Window + S). A small price to pay for getting X-Mouse functionality.

I don't experience issue #2 when I use WinAero Tweaker.

2

Depending on which build of Windows 10 you are running, the menu path to access "Focus Follows Mouse" may be slightly different from some of the instructions in this thread. I was able to get to the proper menu with this sequence:

  1. Click "Start", then select "Control Panel".
  2. Select "Ease of Access Center"
  3. Optional: If the two check boxes for "Always Read This Section Aloud" and "Always Scan This Section" are enabled, you might want to turn them off - they can get pretty annoying.
  4. Select "Make the Mouse Easier to Use" under "Explore all settings"
  5. Click the checkbox next to "Activate a Window by hovering over it with the mouse", under "Make it Easier to Manage Windows".
  6. Click "Apply", then "Okay". You can close the window now.

NOTE: there is about a 1/2-second delay built into this setting by default. You can change the delay time by way of a Registry edit.

  1. Open Regedit.exe
  2. Navigate to this key: [HKEY_CURRENT_USER\Control Panel\Desktop]
  3. In the right pane of the Desktop key, double click/tap on the [ActiveWndTrkTimeout] DWORD to modify it. If you don't see this entry, go back to Step 1 above, and make sure that you did in fact turn on the check box in Steps 5 and 6. In the "Edit DWORD" dialog box that should pop-up, select DECIMAL under BASE.
  4. The default value, 500, equals 500 milliseconds. Change this to a larger value to increase the delay time, or a smaller value to decrease the delay time (speeding up the response).
  5. Click "OK", then close Regedit.
  6. Sign out and sign back in, or restart the computer to apply the change.
1
1

Using the method to achieve the sloppy mouse behavior, that I'm so accustomed to, from previous versions of windows and linux from the post. I do not experience issue #2 that you are having. Issue #1 that you and all will have when using this registry modification is not an issue. It does exactly as expected because you have changed the way focus is handled in windows with this modification. Using the windows key brings the mouse into the start menu not the search menu so it gets focus, not the search menu. So, if you wish to use search either click in the search bar or magnification icon (depending on your settings for its appearance) or use the Win+S key combo and it will do the right thing.

1

To solve issue #2 on Windows 10

2) When you open Start, Search or Notifications by clicking on them, they close before you can interact with them.

All you need to do is:

  • Press Windows + X
  • Control panel
  • Ease of Access
  • Change how your mouse works
  • Enable the checkbox: Prevent windows from being automatically arranged when moved to the edge of the screen

No need for third-party software.

2
  • This setting is not found in Win 10 (any more?) Aug 19, 2020 at 16:46
  • 1
    Works for me (Windows 10)! I can live that 'activate' also means 'raise the window'. ;-)
    – andiba
    Jan 14, 2021 at 7:28
1

Set Regkey HKCU\Control Panel\Desktop\ActiveWndTrackTimeout to something higher than 0 to Setup delay unless other window gets active

1
  • 4
    Fix your key; it's Trk not Track; e.g. ActiveWndTrkTimeout. I have no idea what the Track one does but changing the Trk one is what works for me.
    – lumpynose
    Oct 5, 2018 at 20:45
0

I haven't tested Winaero yet because:

  1. I'm not keen on running unknown software from the internet.
  2. As I have upgraded all PC's I use from Windows 7 to Windows 10, the Windows 7 "Activate a window by hovering over it with the mouse" setting has continued to be in effect in Windows 10, even though there seems to be no method of setting this in the Windows 10 GUI.

I haven't found these workarounds anywhere on the internet yet, so I'll document here for others.

Using the following workarounds, makes using Windows 10 in Xmouse mode practical:

  1. Switching to another window when there are multiple windows available via the app icon in the taskbar:

    Do NOT click the app icon in the taskbar before trying to select a window. If you do, as soon as you move the mouse pointer above the taskbar, the windows will disappear. Just hover above the app icon until the windows appear, then you can move the pointer into the one you need.

  2. Switching to another virtual desktop or app using the task view button:

    • Click on task view button.
    • Click again and hold button down.
    • Move pointer into required task or virtual desktop.
    • Release mouse button, then click again.

Note: the Windows 10 "Scroll inactive windows when I hover over them" setting is a useful addition (see Start -> Settings -> Devices -> Mouse & Touchpad). This seems independent from Xmouse functionality and ON seems to be the default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.