Last active
August 17, 2024 23:35
-
-
Save luoling8192/294c88e0aaa299d259b0af19d3ad86ff to your computer and use it in GitHub Desktop.
Windows Nature Mouse Scrolling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 检查当前用户是否具有管理员权限 | |
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
Write-Host "请以管理员身份运行此脚本。" | |
exit | |
} | |
# 注册表路径 | |
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Enum\HID" | |
# 获取所有以 VID_ 开头的设备 | |
$devices = Get-ChildItem -Path $regPath | Where-Object { $_.PSChildName -like "VID_*" } | |
foreach ($device in $devices) { | |
$deviceParamsPath = "$($device.PSPath)\**\Device Parameters" | |
# 检查 Device Parameters 是否存在 | |
if (Test-Path $deviceParamsPath) { | |
# 设置 FlipFlopWheel 值为 1 | |
Set-ItemProperty -Path $deviceParamsPath -Name "FlipFlopWheel" -Value 1 -Type DWord | |
Write-Host "已将 $($device.PSChildName) 的滚动方向设置为自然滚动。" | |
} | |
} | |
Write-Host "所有设备的滚动方向已更新,请重新插拔设备以使更改生效。" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment