Created
February 17, 2021 16:04
-
-
Save rbleattler/7926380cefa33658c1067150eef49fb7 to your computer and use it in GitHub Desktop.
PowerShell Mouse Scroll Wheel Tools
This file contains 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
function Get-MouseScrollDirection { | |
[CmdletBinding()] | |
param ( | |
) | |
begin { | |
Write-Debug "Enter [$($PSCmdlet.MyInvocation.MyCommand.Name)]..." | |
$PSBoundParameters.Keys.ForEach{ | |
if ($PSBoundParameters.PSItem -is [string]) { | |
Write-Debug "$_ : $($PSBoundParameters.Item($_))" | |
} else { | |
Write-Debug "$_ : $($PSBoundParameters.Item($_).GetType())" | |
} | |
} | |
} | |
process { | |
# Get registry settings | |
$Properties = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device Parameters' -Name FlipFlopWheel -EA 0 | |
$Properties.ForEach{ [pscustomobject]@{ | |
Natural = $([bool]$PSItem.FlipFlopWheel) | |
Path = $PSItem.PSPath | |
} | |
} | |
} | |
end { | |
Write-Debug "Exit [$($PSCmdlet.MyInvocation.MyCommand.Name)]..." | |
} | |
} | |
function Set-MouseScrollDirection { | |
[CmdletBinding()] | |
param ( | |
[ValidateSet('Natural', 'Relative')] | |
[string] | |
$ScrollType | |
) | |
begin { | |
Write-Debug "Enter [$($PSCmdlet.MyInvocation.MyCommand.Name)]..." | |
$PSBoundParameters.Keys.ForEach{ | |
if ($PSBoundParameters.PSItem -is [string]) { | |
Write-Debug "$_ : $($PSBoundParameters.Item($_))" | |
} else { | |
Write-Debug "$_ : $($PSBoundParameters.Item($_).GetType())" | |
} | |
} | |
[int] $ScrollTypeValue = switch ($ScrollType) { | |
'Natural' { | |
1 | |
} | |
'Relative' { | |
0 | |
} | |
} | |
} | |
process { | |
# Get registry settings | |
$Properties = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device Parameters' -Name FlipFlopWheel -EA 0 | |
# Change registry settings | |
# Reverse mouse wheel scroll FlipFlopWheel = 1 | |
# Normal mouse wheel scroll FlipFlopWheel = 0 | |
$Properties.Where{ $PSItem.FlipFlopWheel -ne 1 }.ForEach{ Set-ItemProperty $PSItem.PSPath FlipFlopWheel $ScrollTypeValue } | |
} | |
end { | |
Write-Debug "Exit [$($PSCmdlet.MyInvocation.MyCommand.Name)]..." | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment