Skip to content

Instantly share code, notes, and snippets.

@soda92
Created October 31, 2024 02:15
Show Gist options
  • Select an option

  • Save soda92/24505553302c8dfb3a326719c352adae to your computer and use it in GitHub Desktop.

Select an option

Save soda92/24505553302c8dfb3a326719c352adae to your computer and use it in GitHub Desktop.
Swap mouse button, put this in $profile
# PowerShell script to swap mouse buttons for left-handed mouse users.
# (Make right mouse button the primary button...)
$swapButtons = Add-Type -MemberDefinition @'
[DllImport("user32.dll")]
public static extern bool SwapMouseButton(bool swap);
'@ -Name "NativeMethods" -Namespace "PInvoke" -PassThru
function swapleft {
# Use $true for left-handed mouse and $false for right-handed mouse.
[bool]$returnValue = $swapButtons::SwapMouseButton($true)
}
function swapright {
[bool]$returnValue = $swapButtons::SwapMouseButton($false)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment