-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputHandler.cs
More file actions
101 lines (83 loc) · 2.71 KB
/
InputHandler.cs
File metadata and controls
101 lines (83 loc) · 2.71 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace AutoClicker
{
public class InputHandler
{
[Flags]
public enum MouseEvents
{
Move = 0x00000001,
LeftDown = 0x00000002,
LeftUp = 0x00000004,
RightDown = 0x00000008,
RightUp = 0x00000010,
MiddleDown = 0x00000020,
MiddleUp = 0x00000040,
Absolute = 0x00008000
}
[DllImport("user32.dll", EntryPoint = "SetCursorPos")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetCursorPos(out MousePoint lpMousePoint);
[DllImport("user32.dll")]
private static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
//[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
//private static extern void ();
//keyboard hooks need some research
public static void SetCursorPosition(int x, int y)
{
SetCursorPos(x, y);
}
public static void SetCursorPosition(MousePoint point)
{
SetCursorPos(point.X, point.Y);
}
public static MousePoint GetCursorPosition()
{
MousePoint currentMousePoint;
var gotPoint = GetCursorPos(out currentMousePoint);
if (!gotPoint) { currentMousePoint = new MousePoint(0, 0); }
return currentMousePoint;
}
public static void MouseEvent(MouseEvents value)
{
MousePoint position = GetCursorPosition();
mouse_event
((int)value,
position.X,
position.Y,
0,
0)
;
}
public static void KeyDownEvent()
{
}
public static void KeyUpEvent()
{
}
[StructLayout(LayoutKind.Sequential)]
public struct MousePoint
{
public int X;
public int Y;
public MousePoint(int x, int y)
{
X = x;
Y = y;
}
}
public static void Event_KeyDown(object sender, KeyEventArgs e)
{
Menu._args = new string[] { $"{e.KeyCode}", $"{e.KeyValue}", $"{e.Modifiers}" };
}
}
}