-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
40 lines (30 loc) · 812 Bytes
/
main.cpp
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
#include <windows.h>
#include <iostream>
#include <chrono>
using namespace std;
int main(int argc, char *argv[])
{
int interval = 1000;
if (argc >= 2)
{
interval = atoi(argv[1]);
if (interval < 1)
{
cerr << "Error: interval must be > 1. " << interval << " is not a valid interval value" << endl;
return 1;
}
}
INPUT input{0};
input.type = INPUT_MOUSE;
cout << "Clicking every " << interval << " milliseconds" << endl;
cout << "Press CTRL+C to quit" << endl;
while (true)
{
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1, &input, sizeof(INPUT));
input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(1, &input, sizeof(INPUT));
Sleep(interval);
}
return 0;
}