鼠标连点器

· · 个人记录

#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
#include<bits/stdc++.h>
#include<windows.h>
#include <Windows.h>
#include <stdio.h>
bool f = false, f1 = false, f2;
int b = 30;
#define shift (GetKeyState(VK_SHIFT)&0x8000)
#define ctrl  (GetKeyState(VK_CONTROL)&0x8000)
#define alt   (GetKeyState(VK_MENU)&0x8000)
#define tab   (GetKeyState(VK_TAB)&0x8000)
#define esc   (GetKeyState(VK_ESCAPE)&0x8000)
#define enter (GetKeyState(VK_RETURN)&0x8000)
#define space (GetKeyState(VK_SPACE)&0x8000)
#define one (GetKeyState('1')&0x8000)
#define tow (GetKeyState('2')&0x8000)
void MouseLeftDown() {
    INPUT  Input = {0};
    Input.type = INPUT_MOUSE;
    Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
    SendInput(1, &Input, sizeof(INPUT));
}
void color(int c) {
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void MouseLeftUp() {
    INPUT Input = {0};
    Input.type = INPUT_MOUSE;
    Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
    SendInput(1, &Input, sizeof(INPUT));

}
void ld() {
    MouseLeftUp();
    MouseLeftDown();
    Sleep(b);
    return;
}
using namespace std;
int main() {
    color(0xC);
    cout << "默 认 操 作 如 下:\n";
    color(9);
    cout << "按 下 空 格 开 启 esc 关 闭.\n";
    color(0xA);
    cout << "tab 隐藏 , Crtl 显 示\n";
    color(0xC);
    cout << "enter 加速 , alt 减 速\n";
    color(9);
    cout << "1 键 彻 底 关 闭\n";
    color(0xA);
    cout << "2 键 恢 复 原 速";
    HWND hWnd = GetForegroundWindow();
    srand((unsigned)time(NULL));
    while (1) {
        if (space) {
            f = true;
        }
        if (esc) {
            f = false;
        }
        if (tab) {
            ShowWindow(hWnd, SW_HIDE);
        }
        if (ctrl) {
            ShowWindow(hWnd, SW_SHOW);
        }
        if (enter) {
            if (b > 15) {
                b -= 5;
            }
        }
        if (alt) {
            b += 5;
        }
        if (tow) {
            b = 30;
        }
        if (one) {
            system("color 0f");
            system("cls");
            return 0;
        }
        if (f2 == 1) {
            ShowWindow(hWnd, SW_RESTORE);
        }
        if (f == true) {
            ld();
        }

    }
    return 0;
}