3

When I manually change any mouse settings in the registry using either regedit or PowerShell (MouseSpeed, MouseThreshold1, MouseThreshold2 MouseTrails, etc.) in the registry under

HKEY_CURRENT_USER\Control Panel\Mouse

Nothing applies until Windows is restarted. For example, I set MouseTrails to 6. This should turn MouseTrails setting to the second highest setting, but it isn't applied when I save the value. I restart the machine and then I have a trail following my cursor.

How can I apply these manual mouse registry changes without restarting my computer? Is it even possible? I'm not asking how to set these values via the Control Panel; I know that these settings work just fine through that.

For reference, I am running Windows 10 and have a Logitech G602. The Logitech software is installed in my computer but does not run on startup.

2
  • Did you try logoff/logon instead of a full restart? – DavidPostill Oct 3 '15 at 8:12
  • Logoff/logon works fine because I'm editing under CURRENT_USER but I'm looking for a less intrusive method. Maybe a command in the command prompt? – Jethro Land Oct 3 '15 at 20:53
1

While registry need restart for sure, but try in this way may be it work.

Like you had done some changes in registry, than call task manager by pressing CTRl+Alt+Del. Find the Explorer and Click on End Task. If shut down screen come - - > Click Cancel. Now Select File - -> New Task - -> Enter Explorer and Click OK.

In that you got New Explorer and with recent registry settings. Hope that helps.

Taken from this source: http://www.pctools.com/guides/registry/detail/246/

1
  • I should have mentioned in my original post, this method does not work. – Jethro Land Oct 3 '15 at 5:21
0

A great many registry settings are loaded at different points. Boot time, login, explorer launch et al.

I could be wrong, but I think the HKCU entries would require a sign-out, sign-in cycle at least.

0

These settings can only be changed in a running session through the SystemParametersInfo function. (That's how the mouse settings UI makes its changes.) If you already have a mechanism that writes your desired settings to the Registry, you can follow it up with this PowerShell script to read the Registry entries and apply them with SystemParametersInfo:

Add-Type @"
using System.Runtime.InteropServices;
public class PInvoke {
    [DllImport("user32.dll")] public static extern int SystemParametersInfo(int uiAction, int uiParam, int[] pvParam, int fWinIni);
    [DllImport("user32.dll")] public static extern int SystemParametersInfo(int uiAction, int uiParam, System.IntPtr pvParam, int fWinIni);
}
"@

$mouse = Get-ItemProperty 'HKCU:\Control Panel\Mouse'

# DoubleClickHeight -> SPI_SETDOUBLECLKHEIGHT
[PInvoke]::SystemParametersInfo(0x001E, $mouse.DoubleClickHeight, $null, 0)

# DoubleClickSpeed -> SPI_SETDOUBLECLICKTIME
[PInvoke]::SystemParametersInfo(0x0020, $mouse.DoubleClickSpeed, $null, 0)

# DoubleClickWidth -> SPI_SETDOUBLECLKWIDTH
[PInvoke]::SystemParametersInfo(0x001D, $mouse.DoubleClickWidth, $null, 0)

# MouseHoverHeight -> SPI_SETMOUSEHOVERHEIGHT
[PInvoke]::SystemParametersInfo(0x0065, $mouse.MouseHoverHeight, $null, 0)

# MouseHoverTime -> SPI_SETMOUSEHOVERTIME
[PInvoke]::SystemParametersInfo(0x0067, $mouse.MouseHoverTime, $null, 0)

# MouseHoverWidth -> SPI_SETMOUSEHOVERWIDTH
[PInvoke]::SystemParametersInfo(0x0063, $mouse.MouseHoverWidth, $null, 0)

# MouseSensitivity -> SPI_SETMOUSESPEED
[PInvoke]::SystemParametersInfo(0x0071, 0, [IntPtr][int]$mouse.MouseSensitivity, 0)

# MouseThreshold1, MouseThreshold2, MouseSpeed -> SPI_SETMOUSE
[PInvoke]::SystemParametersInfo(0x0004, 0, [int[]]($mouse.MouseThreshold1, $mouse.MouseThreshold2, $mouse.MouseSpeed), 0)

# MouseTrails -> SPI_SETMOUSETRAILS
[PInvoke]::SystemParametersInfo(0x005D, $mouse.MouseTrails, $null, 0)

# SnapToDefaultButton -> SPI_SETSNAPTODEFBUTTON
[PInvoke]::SystemParametersInfo(0x0060, $mouse.SnapToDefaultButton, $null, 0)

# SwapMouseButtons -> SPI_SETMOUSEBUTTONSWAP
[PInvoke]::SystemParametersInfo(0x0021, $mouse.SwapMouseButtons, $null, 2)

First it declares the SystemParametersInfo native function—twice with slightly different signatures, because the function is strangely inconsistent about how to pass the new setting. Then the script obtains the values of the Mouse Registry key. For each (except a few, mostly sound-related, that seem vestigial), the script calls the system parameters function with the appropriate action/setting code and input format as listed in the documentation. Each call outputs a 1 if successful. When updating the last setting, the SPIF_SENDCHANGE flag (2) is passed to notify other applications that changes have been made.

Since the script gets the data from the Registry, I chose not to have it redundantly update the Registry, but if you decide to adapt the script to set specific mouse settings instead of getting them from the Registry, apply SPIF_UPDATEINIFILE to each SystemParametersInfo call by changing the last parameter from 0 to 1 or from 2 to 3.

Interestingly, the ActiveWindowTracking value is also vestigial—the setting is actually stored as part of the UserPreferencesMask in Desktop—but in case your existing script tried to use the vestigial value, this snippet will apply it for real:

# ActiveWindowTracking -> SPI_SETACTIVEWINDOWTRACKING
[PInvoke]::SystemParametersInfo(0x1001, 0, [IntPtr][int]$mouse.ActiveWindowTracking, 1)

To use the script, save it as a PS1 file, e.g. regmouse.ps1, then you can call it from a command prompt like so:

powershell -executionpolicy bypass -file regmouse.ps1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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