-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
69 lines (62 loc) · 1.92 KB
/
Program.cs
File metadata and controls
69 lines (62 loc) · 1.92 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
namespace AutoclickerConsole
{
using System.Threading;
using System;
using static Input.ME;
using static Input.VK;
using static Input.PI;
using static System.Console;
class Program
{
public static string delay;
public static double result;
static void Main()
{
MainLoop();
}
public static void MainLoop()
{
WriteLine("Enter delay amount: ");
delay = ReadLine();
WriteLine("Type start to start the auto clicker.");
string start = ReadLine();
if (start == "start" || start == "Start")
{
bool createdNew;
var waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "AutoclickerClicking", out createdNew);
if (!createdNew)
{
waitHandle.Set();
return;
}
if (double.TryParse(delay, out result))
{
var timer = new Timer(OnTimerElapsed, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(double.Parse(delay)));
waitHandle.WaitOne();
}
else
{
WriteLine("You did not enter a floating point number");
MainLoop();
}
}
else
{
WriteLine("You entered something other than start.");
MainLoop();
}
}
private static void OnTimerElapsed(object state)
{
Autoclicker();
}
public static void Autoclicker()
{
if (GetAsyncKeyState((int)VK_MBUTTON) != 0)
{
mouse_event((UInt32)MOUSEEVENTF_LEFTDOWN, 0, 0, 0, (UIntPtr)0);
mouse_event((UInt32)MOUSEEVENTF_LEFTUP, 0, 0, 0, (UIntPtr)0);
}
}
}
}