Because of a disability I like to be able to switch from using a right-hand mouse to a left-hand mouse, and back again, every half-hour or so. Doing this from the control panel is slower than I would like. Although I can open the mouse settings controller using main.cpl
on the command line or in a .bat
file, I'd like to to able to do the entire left-right switch using a batch file. Is this possible, and if so, how?
Asked
Active
Viewed 469 times
0

CrimsonDark
- 661
- 9
- 20
1 Answers
2
You can copy the code to the PS1 file and run it with Powershell:
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$SwapButtons = Add-Type -MemberDefinition @'
[DllImport("user32.dll")]
public static extern bool SwapMouseButton(bool swap);
'@ -Name "NativeMethods" -Namespace "PInvoke" -PassThru
[bool]$returnValue = $SwapButtons::SwapMouseButton(!([System.Windows.Forms.SystemInformation]::MouseButtonsSwapped))

Konstantin Baklaev
- 323
- 1
- 3
- 7
-
And for details on how to run the PS1 file from a batch file see https://stackoverflow.com/questions/19335004/how-to-run-a-powershell-script-from-a-batch-file – CrimsonDark Sep 16 '19 at 04:02