-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoclick.cpp
More file actions
58 lines (52 loc) · 1.55 KB
/
Copy pathautoclick.cpp
File metadata and controls
58 lines (52 loc) · 1.55 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
#include <windows.h>
#include <iostream>
bool started = false;
int timer = 10;
int x = 0;
int y = 0;
bool customPos = false;
POINT curserPos;
static void start() {
while (true) {
if (GetAsyncKeyState(VK_PAUSE)) {
started = !started;
if (started) std::cout << "Autoclicker has started.\n";
if (!started) std::cout << "Autoclicker has stopped.\n";
Sleep(400);
}
if (GetAsyncKeyState(VK_INSERT)) {
customPos = !customPos;
if (customPos) {
GetCursorPos(&curserPos);
x = curserPos.x;
y = curserPos.y;
std::cout << "Clicking position set to " << curserPos.x << ", " << curserPos.y << ".\n";
}
if (!customPos) std::cout << "Click position set to mouse.\n";
Sleep(400);
}
if (started) {
if (!customPos) {
GetCursorPos(&curserPos);
x = curserPos.x;
y = curserPos.y;
}
else {
SetCursorPos(x, y);
}
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
Sleep(timer);
}
}
}
int main()
{
std::cout << "Enter ms between click: ";
std::cin >> timer;
std::cout << "===============================================\n";
std::cout << "Press PAUSE to toggle autoclicker.\n";
std::cout << "Press INSERT to toggle click on saved position.\n";
std::cout << "===============================================\n";
start();
}