据我所知,在 cmd/批处理文件中更改鼠标灵敏度是相当困难的(至少我还没有找到正确的方法)。 我尝试添加特定的注册表值并通过重新启动资源管理器进程来重新加载它...但它在系统重新启动之前不起作用。
通过更改 Rundll32 选项,该解决方案似乎更接近。例如:
Rundll32.exe shell32.dll,Control_RunDLL main.cpl @0(或 Rundll32.exe shell32.dll,Control_RunDLL main.cpl,,1) - 显示鼠标设置
和
Rundll32.exe 用户,setdoubleckilcktime [n] - 更改双击速度
是否有类似的可能性可以改变鼠标光标的灵敏度?
最佳答案
这是使用 Powershell 执行此操作的一种方法。
我在 Windows 10 环境中测试了它,但它应该适用于使用该 API 调用的所有 Windows 版本。 (使用 PS 7.2 和 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
引用:
renenyffenegger.ch - Powershell: modify the speed of the mouse
关于powershell - CMD 命令(应用程序)更改鼠标灵敏度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71194925/