SoFunction
Updated on 2025-03-06

C# switches the left and right mouse buttons without modifying it in the control panel


class Program
{
[DllImport("")]
private extern static bool SwapMouseButton(bool fSwap);
//Blog address: http:///bluceyoung

[DllImport("")]
private extern static int GetSystemMetrics(int index);

static void Main(string[] args)
{
int flag = GetSystemMetrics(23);//Get the current mouse setting status
if (flag == 0)//Right-handed habit
{
SwapMouseButton(true);//Set to left hand
}
else//Left hand habit
{
SwapMouseButton(false);//Set as right hand
}
}
}