hello stranger

Welcome to my blog

修改鼠标滚轮滚向

PowerShell 脚本 如果提示禁止运行该脚本,可以查看禁止运行脚本的解决方案 # 获取所有HID-compliant mouse设备 $devices = Get-PnpDevice -Class Mouse # 创建一个对象数组来存储设备信息 $result = @() $id = 1 # 遍历每个设备并获取它们的状态和其他属性 foreach ($device in $devices) { # 本来只用来检测华为鼠标的,但是为了拓展下 # if ($device.FriendlyName -like "*HID-compliant mouse*") # { # } # 获取设备状态 $status = $device.Status # 不在使用的设备不继续 if ($status -ne "OK") { continue } $instanceId = (Get-PnpDeviceProperty -InstanceId $device.InstanceId -KeyName "DEVPKEY_Device_InstanceId").Data $hardwareIds = (Get-PnpDeviceProperty -InstanceId $device.InstanceId -KeyName "DEVPKEY_Device_HardwareIds").Data -join ", " $manufacturer = (Get-PnpDeviceProperty -InstanceId $device.InstanceId -KeyName "DEVPKEY_Device_Manufacturer").Data $deviceDesc = (Get-PnpDeviceProperty -InstanceId $device.InstanceId -KeyName "DEVPKEY_Device_DeviceDesc").Data $deviceParamKeyPath = "HKLM:\SYSTEM\CurrentControlSet\Enum\" + $instanceId + "\Device Parameters" try { $flipFlopWheel = Get-ItemPropertyValue -Path $deviceParamKeyPath -Name "FlipFlopWheel" -ErrorAction Stop } catch { # 如果找不到 FlipFlopWheel 键,设置默认值 $flipFlopWheel = "Not Found" } $result += [PSCustomObject]@{ Id = $id++ Name = $device.Name FlipFlopWheel = $flipFlopWheel InstanceId = $instanceId # # Manufacturer = $manufacturer # 都是 HID-compliant mouse,看不出区别 # Description = $deviceDesc # 都是 HID-compliant mouse,看不出区别 # Status = $status # FriendlyName = $device.FriendlyName # HardwareIds = $hardwareIds } } # 显示结果 $result | Format-Table -AutoSize # 定义了一个函数修改 function Set-FlipFlopWheel { param ( [string]$name, # 只是用来打印名字,无别的功能上的用途 [string]$instanceId ) $deviceParamKeyPath = "HKLM:\SYSTEM\CurrentControlSet\Enum\" + $instanceId + "\Device Parameters" try { Set-ItemProperty -Path $deviceParamKeyPath -Name "FlipFlopWheel" -Value 1 -ErrorAction Stop $newFlipFlopValue = Get-ItemPropertyValue -Path $deviceParamKeyPath -Name "FlipFlopWheel" -ErrorAction Stop Write-Output "device $( $name )'s FlipFlopWheel value has been modified to $newFlipFlopValue." } catch { Write-Output "try to modify device $( $name )'s FlipFlopWheel value err: $_" } } # 如果只有一个结果 并且 值不为 1 if ($result.Count -eq 1 -and $result.FlipFlopWheel -ne 1) { # 获取用户输入 $userInput = Read-Host "do you want to modify FlipFlopWheel to 1 ? (Y/N)" if ($userInput -eq "Y" -or $userInput -eq "y") { Set-FlipFlopWheel -name $result.Name -instanceId $result.InstanceId } } # 如果有多个设备,则让用户输入 id 来选择哪个设备 elseif ($result.Count -gt 1) { Write-Output "multi mouse device exist, please check and modify it by yourself" $selectedId = Read-Host "Input the id you wanna modify " $selectedDevice = $result | Where-Object { $_.Id -eq [int]$selectedId } if ($selectedDevice) { # 获取用户输入 $userInput = Read-Host "do you want to modify $selectedId FlipFlopWheel to 1 ? (Y/N)" if ($userInput -eq "Y" -or $userInput -eq "y") { Set-FlipFlopWheel -name $selectedDevice.Name -instanceId $selectedDevice.InstanceId } } else { Write-Output "illegal device id." } } else { Write-Output "HID-compliant mouse's FlipFlopWheel value already 1" } Write-Output "" pause

August 6, 2025 · 377 words · dayday

神武

June 24, 2025 · 160 words · dayday

执行ps1遇到系统上禁止运行脚本的报错

June 24, 2025 · 57 words · dayday

如何更改电脑本地账户用户名

经常电脑用户名被设置成了 Administrator 甚至中文名, 如何完全改掉呢?

June 23, 2025 · 200 words · dayday

命令行有意思的小工具

有一些好玩的命令行小工具, 可以增添乐趣

May 28, 2025 · 161 words · dayday

Pprof使用实践

pprof 是 golang 性能监控的工具, 这里是我自己的一些使用经验

May 13, 2025 · 94 words · dayday

“Com.docker.vmnetd”将对你的电脑造成伤害。 如何解决

January 11, 2025 · 45 words · dayday

Dfs

December 3, 2024 · 778 words · dayday

不定长滑窗

November 24, 2024 · 517 words · dayday

定长滑窗

November 22, 2024 · 1322 words · dayday