-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSend.cs
118 lines (106 loc) · 3.63 KB
/
Send.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Decompiled with JetBrains decompiler
// Type: ReplaySeeker.Send
// Assembly: ReplaySeeker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
using System;
using System.Runtime.InteropServices;
namespace ReplaySeeker
{
public class Send
{
[DllImport("user32.dll")]
private static extern IntPtr GetMessageExtraInfo();
[DllImport("user32")]
private static extern int SendInput(int nInputs, Send.INPUT[] pInputs, int cbSize);
[DllImport("user32")]
private static extern int SendInput(int nInputs, ref Send.INPUT pInputs, int cbSize);
public static void MouseInput(Send.MOUSEINPUT[] mInputs)
{
Send.INPUT[] pInputs = new Send.INPUT[mInputs.Length];
for (int index = 0; index < pInputs.Length; ++index)
{
pInputs[index] = new Send.INPUT();
pInputs[index].type = 0;
pInputs[index].mi = mInputs[index];
pInputs[index].mi.dwExtraInfo = Send.GetMessageExtraInfo();
}
Send.SendInput(pInputs.Length, pInputs, Marshal.SizeOf(typeof (Send.INPUT)));
}
public static void KeyboardInput(Send.KEYBDINPUT[] kbInputs)
{
Send.INPUT[] pInputs = new Send.INPUT[kbInputs.Length];
for (int index = 0; index < pInputs.Length; ++index)
{
pInputs[index] = new Send.INPUT();
pInputs[index].type = 1;
pInputs[index].ki = kbInputs[index];
pInputs[index].ki.dwExtraInfo = Send.GetMessageExtraInfo();
}
Send.SendInput(pInputs.Length, pInputs, Marshal.SizeOf(typeof (Send.INPUT)));
}
public static void KeyboardInput(Send.KEYBDINPUT kbInput)
{
Send.INPUT pInputs = new Send.INPUT();
pInputs.type = 1;
pInputs.ki = kbInput;
pInputs.ki.dwExtraInfo = Send.GetMessageExtraInfo();
Send.SendInput(1, ref pInputs, Marshal.SizeOf(typeof (Send.INPUT)));
}
public class Constants
{
public const int INPUT_MOUSE = 0;
public const int INPUT_KEYBOARD = 1;
public const int INPUT_HARDWARE = 2;
public const int MOUSEEVENTF_MOVE = 1;
public const int MOUSEEVENTF_LEFTDOWN = 2;
public const int MOUSEEVENTF_LEFTUP = 4;
public const int MOUSEEVENTF_RIGHTDOWN = 8;
public const int MOUSEEVENTF_RIGHTUP = 16;
public const int MOUSEEVENTF_MIDDLEDOWN = 32;
public const int MOUSEEVENTF_MIDDLEUP = 64;
public const int MOUSEEVENTF_XDOWN = 128;
public const int MOUSEEVENTF_XUP = 256;
public const int MOUSEEVENTF_WHEEL = 2048;
public const int MOUSEEVENTF_VIRTUALDESK = 16384;
public const int MOUSEEVENTF_ABSOLUTE = 32768;
public const uint KEYEVENTF_EXTENDEDKEY = 1;
public const uint KEYEVENTF_KEYUP = 2;
public const uint KEYEVENTF_UNICODE = 4;
public const uint KEYEVENTF_SCANCODE = 8;
}
public struct MOUSEINPUT
{
public int dx;
public int dy;
public uint mouseData;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
public struct KEYBDINPUT
{
public ushort wVk;
public ushort wScan;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
public struct HARDWAREINPUT
{
public uint uMsg;
public ushort wParamL;
public ushort wParamH;
}
[StructLayout(LayoutKind.Explicit)]
public struct INPUT
{
[FieldOffset(0)]
public int type;
[FieldOffset(4)]
public Send.MOUSEINPUT mi;
[FieldOffset(4)]
public Send.KEYBDINPUT ki;
[FieldOffset(4)]
public Send.HARDWAREINPUT hi;
}
}
}