question

youki avatar image
0 Votes"
youki asked TimonYang-MSFT commented

How to enable/ disable inactive window scrolling by code

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

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


Regards

dotnet-csharpwindows-forms
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@youki
May I know if you have a chance to check my answer?
Is the way to modify the registry acceptable? If you have any questions, please feel free to let me know.

0 Votes 0 ·

1 Answer

TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered

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.


2.png (6.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.