Reputation: 51
As I realised it is quite difficult (at least I have not found a right soultion) to change mouse sensitivity in cmd/by batch file. I have tried to add specific registry value and reloade it by restarting explorer process... but it does not work till system restart.
It sems to that solution is much closer by changing Rundll32 options. For example:
Rundll32.exe shell32.dll,Control_RunDLL main.cpl @0 (or Rundll32.exe shell32.dll,Control_RunDLL main.cpl,,1) - displays mouse settings
and
Rundll32.exe user, setdoubleckilcktime [n] - changing double click speed
Is there a similar possibility that will allow to change mouse cursor sensitivity?
Upvotes: 4
Views: 8980
Reputation: 10333
Here's a way to do it with Powershell.
I tested it on a Windows 10 environment but it should work on all Windows version that use that API call. (Tested with PS 7.2 and Windows Powershell 5.1)
Function Set-MouseSpeed {
[CmdletBinding()]
param (
[validateRange(1, 20)]
[int] $Value
)
$winApi = add-type -name user32 -namespace tq84 -passThru -memberDefinition '
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam ,
uint pvParam ,
uint fWinIni
);
'
$SPI_SETMOUSESPEED = 0x0071
$MouseSpeedRegPath = 'hkcu:\Control Panel\Mouse'
Write-Verbose "MouseSensitivity before WinAPI call: $((get-itemProperty $MouseSpeedRegPath).MouseSensitivity)"
$null = $winApi::SystemParametersInfo($SPI_SETMOUSESPEED, 0, $Value, 0)
#
# Calling SystemParametersInfo() does not permanently store the modification
# of the mouse speed. It needs to be changed in the registry as well
#
set-itemProperty $MouseSpeedRegPath -name MouseSensitivity -value $Value
Write-Verbose "MouseSensitivity after WinAPI call: $((get-itemProperty $MouseSpeedRegPath).MouseSensitivity)"
}
Set-MouseSpeed -Value 16 -Verbose
Reference:
renenyffenegger.ch - Powershell: modify the speed of the mouse
Upvotes: 10