-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouseSpinClass.cs
More file actions
55 lines (45 loc) · 1.38 KB
/
Copy pathMouseSpinClass.cs
File metadata and controls
55 lines (45 loc) · 1.38 KB
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
using System.Runtime.InteropServices;
namespace SetMouseForGames
{
internal class MouseSpinClass
{
internal static void DoSpin(int spinValue)
{
MouseInputLowLevel.DoSpinLowLevel(spinValue);
Thread.Sleep(500);
MouseInputLowLevel.DoSpinLowLevel(-spinValue);
}
}
public class MouseInputLowLevel
{
[DllImport("user32.dll", SetLastError = true)]
static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);
const uint INPUT_MOUSE = 0;
const uint MOUSEEVENTF_MOVE = 0x0001;
[StructLayout(LayoutKind.Sequential)]
record struct INPUT
{
public uint type;
public MOUSEINPUT mi;
}
[StructLayout(LayoutKind.Sequential)]
record struct MOUSEINPUT
{
public int dx;
public int dy;
public uint mouseData;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
public static void DoSpinLowLevel(int spinValueLow)
{
INPUT input = new INPUT();
input.type = INPUT_MOUSE;
input.mi.dx = spinValueLow;
input.mi.dy = 0;
input.mi.dwFlags = MOUSEEVENTF_MOVE;
SendInput(1, new INPUT[] { input }, Marshal.SizeOf(typeof(INPUT)));
}
}
}