-
Notifications
You must be signed in to change notification settings - Fork 0
/
swap.cs
61 lines (54 loc) · 1.38 KB
/
swap.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ayeseeem@gmail.com 2011-11-08
using System.Runtime.InteropServices;
using System;
using System.Windows.Forms;
class SwapMouse
{
[DllImport("user32.dll")]
static extern Int32 SwapMouseButton(Int32 bSwap);
static void Main(string[] args)
{
if (args.Length == 0)
{
SwapButtons();
}
else if (args.Length > 0 && String.Compare(args[0], "/R", true) == 0)
// set for right-handed
SetButtonsNormal();
else if (args.Length > 0 && String.Compare(args[0], "/L", true) == 0)
// set for left-handed
SetButtonsSwapped();
else
{
PrintUsage();
}
}
static void PrintUsage()
{
Console.WriteLine("swaps the mouse buttons");
Console.WriteLine(" no args - toggles left and right");
Console.WriteLine(" /R - set for normal Right-handed use");
Console.WriteLine(" /L - set for normal Left-handed use");
}
static void SwapButtons()
{
// try to toggle
bool swapped = SystemInformation.MouseButtonsSwapped;
if (swapped)
{
SetButtonsNormal();
}
else
{
SetButtonsSwapped();
}
}
static void SetButtonsNormal()
{
SwapMouseButton(0);
}
static void SetButtonsSwapped()
{
SwapMouseButton(1);
}
}