다음을 통해 공유


Swap mouse buttons using PowerShell

Requirement

Need to swap the mouse button.

PowerShell Code

<#
.Synopsis
   Swaps Mouse Buttons.
.DESCRIPTION
   Switch the mouse click left to right
.EXAMPLE
   Swap-MouseKeys
.Contact
   chendrayan.exchange@hotmail.com
.NOTE
    Log off and Log on back
#>
function Swap-MouseButtons
{
    Begin
    {
        Write-Host "Swapping your Mouse Buttons..."  -ForegroundColor Yellow
    }
    Process
    {
        $currentValue = Get-ItemProperty 'HKCU:\Control Panel\Mouse' | Select SwapMouseButtons
        if($currentValue.SwapMouseButtons -eq 0) {
        Write-Host "No Swap Enabled - It's Set to default" -ForegroundColor Yellow
        }
        else{
        Set-ItemProperty 'HKCU:\Control Panel\Mouse' -Name SwapMouseButtons -Value 1
        }
    }
    End
    {
        Write-Host "Right and Left Click Swapped...Log off and Log on!!!" -ForegroundColor Yellow
    }
}

Help

help Get-ItemProperty

help Set-ItemProperty

Note

Do back up before modifying the registry values.