forked from yangzhongke/NetAutoGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouseHelper.cs
More file actions
68 lines (57 loc) · 1.77 KB
/
MouseHelper.cs
File metadata and controls
68 lines (57 loc) · 1.77 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
56
57
58
59
60
61
62
63
64
65
66
67
68
using NetAutoGUI.Internals;
using System;
using Vanara.PInvoke;
namespace NetAutoGUI.Windows
{
internal class MouseHelper
{
public static void MoveTo(int x, int y)
{
User32.SetCursorPos(x, y)
.CheckReturn(nameof(User32.SetCursorPos));
}
public static void LeftButtonDown()
{
User32.mouse_event(User32.MOUSEEVENTF.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero);
}
public static void LeftButtonUp()
{
User32.mouse_event(User32.MOUSEEVENTF.MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero);
}
public static void LeftButtonClick()
{
LeftButtonDown();
LeftButtonUp();
}
public static void RightButtonDown()
{
User32.mouse_event(User32.MOUSEEVENTF.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, IntPtr.Zero);
}
public static void RightButtonUp()
{
User32.mouse_event(User32.MOUSEEVENTF.MOUSEEVENTF_RIGHTUP, 0, 0, 0, IntPtr.Zero);
}
public static void RightButtonClick()
{
RightButtonDown();
RightButtonUp();
}
public static void MiddleButtonDown()
{
User32.mouse_event(User32.MOUSEEVENTF.MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, IntPtr.Zero);
}
public static void MiddleButtonUp()
{
User32.mouse_event(User32.MOUSEEVENTF.MOUSEEVENTF_MIDDLEUP, 0, 0, 0, IntPtr.Zero);
}
public static void MiddleButtonClick()
{
MiddleButtonDown();
MiddleButtonUp();
}
public static void Scroll(int delta)
{
User32.mouse_event(User32.MOUSEEVENTF.MOUSEEVENTF_WHEEL, 0, 0, delta, IntPtr.Zero);
}
}
}