-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClickMate.cpp
More file actions
44 lines (43 loc) · 1.33 KB
/
ClickMate.cpp
File metadata and controls
44 lines (43 loc) · 1.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
#include <iostream>
#include <windows.h>
#include <conio.h>
int main()
{
bool isLeftClick;
std::cout << "Choose Mouse Type: \n";
std::cout << "\t1. Left-click \n";
std::cout << "\t2. Right-click \n";
std::cout << "-> ";
isLeftClick = std::cin.get() == '1';
std::cout << (isLeftClick ? "Left" : "Right") << "-click chosen.\n";
//
INPUT inp{0};
inp.type = INPUT_MOUSE;
inp.mi.dx = 0;
inp.mi.dy = 0;
auto mouseDown = isLeftClick ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN;
auto mouseUp = isLeftClick ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP;
bool clickEnabled = 0;
//
std::cout << "Press ALT + C to Turn On/Off...\n";
while (true)
{
if (GetKeyState(VK_MENU) < 0 && GetKeyState(0x43) < 0) // ALT + C
{
Sleep(800);
clickEnabled = !clickEnabled; // turn on/off autoclicker
}
if (clickEnabled)
{
// start mouse click
inp.mi.dwFlags = mouseDown;
SendInput(1, &inp, sizeof(INPUT));
// stop mouse click
inp.mi.dwFlags = mouseUp;
SendInput(1, &inp, sizeof(INPUT));
// wait
Sleep(30); // Sleep(milliseconds) -> CPS (Clicks Per Second) can be modified here.
}
}
getch();
}