How to enable/ disable inactive window scrolling by code

youki 1,021 Reputation points
2021-05-05T11:05:03.003+00:00

Hello,
couldn't find anything on the internet and it seems it's not included in SystemParametersInfo:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa

In Windows10: Mouse settings -> Scroll inactive windows when I hover over them

Regards

Developer technologies Windows Forms
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. Timon Yang-MSFT 9,606 Reputation points
    2021-05-10T09:09:01.997+00:00

    I did not find an API to set it, but we can do it by modifying the registry.

    Computer\HKEY_CURRENT_USER\Control Panel\Desktop

            RegistryKey myKey = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);  
            if (myKey != null)  
            {  
                myKey.SetValue("MouseWheelRouting",2);  
                myKey.Close();  
            }  
            textBox1.Text = GetValue().ToString();  
    

    A value of 2 means on, and a value of 0 means off.

    Two things need to be noted. One is that modifying the registry requires administrator rights, and the other is that the modification of the registry requires restarting the computer to take effect.

    To prevent unnecessary troubles, before modifying the registry, I suggest you back up it first.

    95144-2.png


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.