-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse.h
29 lines (28 loc) · 841 Bytes
/
mouse.h
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
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
static void MouseClick(const unsigned int x, const unsigned int y,
const unsigned char type) {
SetCursorPos(x, y);
INPUT input;
ZeroMemory(&input, sizeof(input));
input.type = INPUT_MOUSE;
switch (type) {
case 1:
input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
SendInput(1, &input, sizeof(input));
input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
break;
case 2:
input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
SendInput(1, &input, sizeof(input));
input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
break;
default:
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1, &input, sizeof(input));
input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
}
SendInput(1, &input, sizeof(input));
}