1

I accidently did this command in powershell windows 10 and my mouse buttons are swapped.

rundll32.exe user32.dll,SwapMouseButton

How to fix it?

I was testing this command like in a youtube shorts. But I don't know how to fix it.

Sreehari S
  • 11
  • 2

1 Answers1

2

SwapMouseButton is a native Windows API function that can be called from PowerShell using P/Invoke.

Add the P/Invoke definition using Add-Type and then call the API function, passing $false to revert to normal mouse button behavior:

# Add the P/Invoke API definition
$api = Add-Type -PassThru -Namespace Win32 -Name Win32SwapMouseButton -MemberDefinition @'
[DllImport("user32.dll")]
public static extern bool SwapMouseButton(bool fSwap);
'@

# Call the API to restore normal mouse button behavior
$api::SwapMouseButton($false)

Likewise, you can pass $true to swap mouse buttons again, without having to resort to the rundll32 hack.

zett42
  • 25,437
  • 3
  • 35
  • 72