How do you enable focus follows mouse in Windows 10

50

14

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?

Gordon Wrigley

Posted 2015-08-08T21:32:49.407

Reputation: 810

A workaround for issue #1 is to click the magnifying glass (search) instead. The shortcut key for this is Window + S. – andz – 2015-08-11T18:33:41.220

1You 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 – 2015-08-11T18:33:57.137

Answers

36

Use X-Mouse Controls, 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.

ArthurChamz

Posted 2015-08-08T21:32:49.407

Reputation: 543

26

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

golvok

Posted 2015-08-08T21:32:49.407

Reputation: 369

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 – 2018-01-22T17:36:16.017

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. – bitsoflogic – 2020-02-06T00:17:08.353

For a permanent SloppyFocusMouse, I changed Computer\HKEY_CURRENT_USER\Control Panel\Desktop 's UserPreferenceMask's first hex data from "9e" to "9f" – bitsoflogic – 2020-02-06T00:19:30.817

11

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.

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.

aleixosk

Posted 2015-08-08T21:32:49.407

Reputation: 119

3However, 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 – 2017-09-08T18:00:26.250

Applying the registry modifications stops auto raise. – aleixosk – 2017-09-09T20:45:04.213

9

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 )

Matthijs

Posted 2015-08-08T21:32:49.407

Reputation: 191

2Hello, 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 – 2019-05-13T19:26:36.260

There, I've fleshed out the explanation. – Matthijs – 2019-05-14T21:26:36.907

1Great! I'm glad to be your first upvote, hope a lot more will come :D – DGoiko – 2019-05-14T21:41:36.363

1

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

Volker

Posted 2015-08-08T21:32:49.407

Reputation: 11

2Fix 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 – 2018-10-05T20:45:36.530

1

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.

andz

Posted 2015-08-08T21:32:49.407

Reputation: 191

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.

sudo

Posted 2015-08-08T21:32:49.407

Reputation: 11

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.

Chris Good

Posted 2015-08-08T21:32:49.407

Reputation: 103

-2

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.

Vincent Ho

Posted 2015-08-08T21:32:49.407

Reputation: 1