-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
244 lines (206 loc) · 7.33 KB
/
Form1.cs
File metadata and controls
244 lines (206 loc) · 7.33 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace MonguGamerPro
{
public partial class Form1 : Form
{
public const byte VK_NUMLOCK = 0x90;
public const byte VK_CAPSLOCK = 0x14;
public const byte VK_SCROLL = 0x91;
public const byte VK_F13 = 0x7C;
public const byte VK_F14 = 0x7D;
public const byte VK_F15 = 0x7E;
public const byte VK_F16 = 0x7F;
public const byte VK_F17 = 0x80;
public const byte VK_F18 = 0x81;
public const byte VK_F19 = 0x82;
public const byte VK_F20 = 0x83;
public const byte VK_F21 = 0x84;
public const byte VK_F22 = 0x85;
public const byte VK_F23 = 0x86;
public const byte VK_F24 = 0x87;
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
const int KEYEVENTF_KEYDOWN = 0x0;
public int delay = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
numLockLabelUpdate(Control.IsKeyLocked(Keys.NumLock));
capsLockLabelUpdate(Control.IsKeyLocked(Keys.CapsLock));
scrollLockLabelUpdate(Control.IsKeyLocked(Keys.Scroll));
}
private void numLockButton_Click(object sender, EventArgs e)
{
bool isKeyLocked = Control.IsKeyLocked(Keys.NumLock);
if (isKeyLocked)
{
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
}
else
{
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYDOWN, (UIntPtr)0);
}
numLockLabelUpdate(!isKeyLocked);
}
private void capsLockButton_Click(object sender, EventArgs e)
{
bool isKeyLocked = Control.IsKeyLocked(Keys.CapsLock);
if (isKeyLocked)
{
keybd_event(VK_CAPSLOCK, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event(VK_CAPSLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
}
else
{
keybd_event(VK_CAPSLOCK, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event(VK_CAPSLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYDOWN, (UIntPtr)0);
}
capsLockLabelUpdate(!isKeyLocked);
}
private void scrolLockButton_Click(object sender, EventArgs e)
{
bool isKeyLocked = Control.IsKeyLocked(Keys.Scroll);
if (isKeyLocked)
{
keybd_event(VK_SCROLL, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event(VK_SCROLL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
}
else
{
keybd_event(VK_SCROLL, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event(VK_SCROLL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYDOWN, (UIntPtr)0);
}
scrollLockLabelUpdate(!isKeyLocked);
}
private void numLockLabelUpdate(bool isKeyLocked)
{
if (isKeyLocked)
{
numLockLabel.Text = "ON";
numLockLabel.BackColor = Color.Green;
}
else
{
numLockLabel.Text = "OFF";
numLockLabel.BackColor = Color.Red;
}
}
private void capsLockLabelUpdate(bool isKeyLocked)
{
if (isKeyLocked)
{
capsLockLabel.Text = "ON";
capsLockLabel.BackColor = Color.Green;
}
else
{
capsLockLabel.Text = "OFF";
capsLockLabel.BackColor = Color.Red;
}
}
private void scrollLockLabelUpdate(bool isKeyLocked)
{
if (isKeyLocked)
{
scrollLockLabel.Text = "ON";
scrollLockLabel.BackColor = Color.Green;
}
else
{
scrollLockLabel.Text = "OFF";
scrollLockLabel.BackColor = Color.Red;
}
}
private void showClockButton_Click(object sender, EventArgs e)
{
}
private void showCrosshairButton_Click(object sender, EventArgs e)
{
}
private void fKeyButton_Click(object sender, EventArgs e)
{
Text = ((Button)sender).Text;
if ((Button)sender == f14Button)
Text = "Yes";
delayTextBox.Enabled = false;
f13Button.Enabled = false;
f14Button.Enabled = false;
f15Button.Enabled = false;
f16Button.Enabled = false;
f17Button.Enabled = false;
f18Button.Enabled = false;
f19Button.Enabled = false;
f20Button.Enabled = false;
f21Button.Enabled = false;
f22Button.Enabled = false;
f23Button.Enabled = false;
f24Button.Enabled = false;
delay = Convert.ToInt32(delayTextBox.Text);
fKeyTimer.Start();
}
private void fKeyTimer_Tick(object sender, EventArgs e)
{
int countdown = Convert.ToInt32(delayTextBox.Text);
if(countdown <= 1)
{
delayTextBox.Enabled = true;
f13Button.Enabled = true;
f14Button.Enabled = true;
f15Button.Enabled = true;
f16Button.Enabled = true;
f17Button.Enabled = true;
f18Button.Enabled = true;
f19Button.Enabled = true;
f20Button.Enabled = true;
f21Button.Enabled = true;
f22Button.Enabled = true;
f23Button.Enabled = true;
f24Button.Enabled = true;
delayTextBox.Text = delay.ToString();
fKeyTimer.Stop();
}
else
{
delayTextBox.Text = Convert.ToString(countdown - 1);
}
}
private void stopDelayButton_Click(object sender, EventArgs e)
{
delayTextBox.Text = "0";
fKeyTimer_Tick(sender, e);
}
private string makeNumber(string text)
{
string outputText = "";
for (int i = 0; i < text.Length; i++)
{
if("0123456789".Contains(text[i]))
outputText += text[i];
}
outputText = outputText.TrimStart('0');
if (outputText == "")
outputText = "0";
return outputText;
}
private void delayTextBox_Validating(object sender, CancelEventArgs e)
{
delayTextBox.Text = makeNumber(delayTextBox.Text);
}
}
}