• 个人简介

    每日一乐

    (取自msn)

    MC

    摸鱼勿点

    scratch

    游戏

    博客

    MC

    视频

    留个纪念

    高速连点器(F6开始/暂停F12停止运行)

    
    #include <windows.h>
    #include <iostream>
    #include <thread>
    #include <atomic>
    #include <random>
    
    // 全局控制标志
    std::atomic<bool> g_isRunning(false);
    std::atomic<bool> g_exitProgram(false);
    
    // 配置参数:极短间隔以实现高速点击
    struct Config {
        int minIntervalMs = 0;   // 最小间隔毫秒
        int maxIntervalMs = 1;   // 最大间隔毫秒,保持微小随机性防检测
    };
    
    Config config;
    
    // 模拟一次左键点击
    void click() {
        INPUT input[2] = {};
        
        // 按下
        input[0].type = INPUT_MOUSE;
        input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
        
        // 抬起
        input[1].type = INPUT_MOUSE;
        input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
        
        SendInput(2, input, sizeof(INPUT));
    }
    
    // 热键监听线程
    void hotkeyListener() {
        while (!g_exitProgram) {
            // F6 启停
            if (GetAsyncKeyState(VK_F6) & 0x8000) {
                g_isRunning = !g_isRunning;
                std::cout << "\r[状态] " << (g_isRunning ? "高速运行中..." : "已暂停   ") << std::flush;
                Sleep(200); // 防抖
            }
            // F12 退出
            if (GetAsyncKeyState(VK_F12) & 0x8000) {
                g_exitProgram = true;
            }
            Sleep(10);
        }
    }
    
    int main() {
        std::cout << "========================================" << std::endl;
        std::cout << "   C++ 极速鼠标连点器 (High Speed)" << std::endl;
        std::cout << "========================================" << std::endl;
        std::cout << "[提示] F6: 启动/停止" << std::endl;
        std::cout << "[提示] F12: 退出程序" << std::endl;
        std::cout << "[警告] 请确保以管理员身份运行以获得最佳兼容性" << std::endl;
        std::cout << "----------------------------------------" << std::endl;
    
        // 启动热键监听线程
        std::thread hkThread(hotkeyListener);
    
        // 随机数生成器
        std::random_device rd;
        std::mt19937 gen(rd());
        std::uniform_int_distribution<> dis(config.minIntervalMs, config.maxIntervalMs);
    
        long long count = 0;
        while (!g_exitProgram) {
            if (g_isRunning) {
                click();
                count++;
                
                // 极速模式下的休眠,尽量小但保留微小随机性
                int sleepTime = dis(gen);
                if (sleepTime < 1) sleepTime = 1;
                std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
            } else {
                std::this_thread::sleep_for(std::chrono::milliseconds(50));
            }
        }
    
        if (hkThread.joinable()) {
            hkThread.join();
        }
        
        std::cout << "\n程序已退出。总点击次数: " << count << std::endl;
        return 0;
    }
    
    

    C++内加编译命令:

    -std=gnu++11
    
    -O2 -std=c++14
    
    
    #include <windows.h>
    #include <iostream>
    #include <thread>
    #include <chrono>
    #include <random>
    #include <atomic>
    
    // 全局状态标志
    std::atomic<bool> g_isRunning(false);
    std::atomic<bool> g_exitProgram(false);
    
    // 配置结构体
    struct ClickerConfig {
        int baseIntervalMs = 50;      // 基础点击间隔
        int varianceMs = 20;          // 随机波动范围
        bool useRandomVariance = true;// 是否启用随机间隔
    };
    
    // 模拟一次鼠标左键点击
    void performClick() {
        INPUT input[2] = {};
        
        // 按下左键
        input[0].type = INPUT_MOUSE;
        input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
        
        // 抬起左键
        input[1].type = INPUT_MOUSE;
        input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
        
        SendInput(2, input, sizeof(INPUT));
    }
    
    // 检查热键状态
    void checkHotkeys() {
        // F6: 切换运行状态
        if (GetAsyncKeyState(VK_F6) & 0x8000) {
            g_isRunning = !g_isRunning;
            std::cout << "\r[状态] 连点器已" << (g_isRunning ? "启动" : "暂停") << "       " << std::endl;
            Sleep(300); // 防抖延迟
        }
        
        // F12: 退出程序
        if (GetAsyncKeyState(VK_F12) & 0x8000) {
            g_exitProgram = true;
        }
    }
    
    int main() {
        // 提升控制台输出刷新率
        std::ios::sync_with_stdio(false);
        
        std::cout << "========================================" << std::endl;
        std::cout << "   C++ 轻量级鼠标连点器 v1.0" << std::endl;
        std::cout << "========================================" << std::endl;
        std::cout << "[提示] 请按 F6 启动/暂停连点" << std::endl;
        std::cout << "[提示] 请按 F12 退出程序" << std::endl;
        std::cout << "----------------------------------------" << std::endl;
    
        ClickerConfig config;
        std::random_device rd;
        std::mt19937 gen(rd());
        std::uniform_int_distribution<> dis(
            config.baseIntervalMs - config.varianceMs, 
            config.baseIntervalMs + config.varianceMs
        );
    
        long long clickCount = 0;
        auto lastPrintTime = std::chrono::steady_clock::now();
    
        while (!g_exitProgram) {
            checkHotkeys();
    
            if (g_isRunning) {
                performClick();
                clickCount++;
    
                // 每秒打印一次统计信息,避免频繁IO影响性能
                auto now = std::chrono::steady_clock::now();
                if (std::chrono::duration_cast<std::chrono::seconds>(now - lastPrintTime).count() >= 1) {
                    std::cout << "\r[运行中] 累计点击: " << clickCount << " 次      " << std::flush;
                    lastPrintTime = now;
                }
    
                // 计算休眠时间
                int sleepTime = config.useRandomVariance ? dis(gen) : config.baseIntervalMs;
                if (sleepTime < 1) sleepTime = 1; // 确保最小休眠时间为1ms
                
                std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
            } else {
                // 暂停状态下降低CPU占用
                std::this_thread::sleep_for(std::chrono::milliseconds(50));
            }
        }
    
        std::cout << "\n程序已退出。" << std::endl;
        return 0;
    }
    
    
    
    #include <windows.h>
    #include <iostream>
    #include <thread>
    #include <atomic>
    #include <random>
    #include <chrono>
    
    // 全局控制标志
    std::atomic<bool> g_isRunning(false);
    std::atomic<bool> g_exitProgram(false);
    
    // 配置参数
    struct Config {
        int minIntervalMs = 1;   // 最小间隔毫秒
        int maxIntervalMs = 5;  // 最大间隔毫秒
    };
    
    Config config;
    
    // 模拟一次左键点击
    void click() {
        INPUT input[2] = {};
        
        // 按下
        input[0].type = INPUT_MOUSE;
        input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
        
        // 抬起
        input[1].type = INPUT_MOUSE;
        input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
        
        SendInput(2, input, sizeof(INPUT));
    }
    
    // 检查特定组合键是否被按下
    bool isKeyPressed(int vk) {
        return (GetAsyncKeyState(vk) & 0x8000) != 0;
    }
    
    // 热键监听线程
    void hotkeyListener() {
        bool lastCtrl = false;
        bool lastAlt = false;
        bool lastZ = false;
        bool lastX = false;
    
        while (!g_exitProgram) {
            bool currCtrl = isKeyPressed(VK_CONTROL);
            bool currAlt = isKeyPressed(VK_MENU); // VK_MENU 是 Alt
            bool currZ = isKeyPressed('Z');
            bool currX = isKeyPressed('X');
    
            // 检测 Ctrl + Alt + Z (启动/停止)
            if (currCtrl && currAlt && currZ && !lastZ) {
                g_isRunning = !g_isRunning;
                std::cout << "\r[状态] " << (g_isRunning ? "运行中 (Ctrl+Alt+Z暂停)" : "已暂停 (Ctrl+Alt+Z启动)") << "       " << std::flush;
            }
    
            // 检测 Ctrl + Alt + X (退出)
            if (currCtrl && currAlt && currX && !lastX) {
                g_exitProgram = true;
                std::cout << "\n正在退出程序..." << std::endl;
            }
    
            lastCtrl = currCtrl;
            lastAlt = currAlt;
            lastZ = currZ;
            lastX = currX;
    
            Sleep(10); // 轮询间隔
        }
    }
    
    int main() {
        std::cout << "========================================" << std::endl;
        std::cout << "   C++ 自定义热键鼠标连点器" << std::endl;
        std::cout << "========================================" << std::endl;
        std::cout << "[提示] Ctrl + Alt + Z: 启动/停止" << std::endl;
        std::cout << "[提示] Ctrl + Alt + X: 退出程序" << std::endl;
        std::cout << "[警告] 请以管理员身份运行以确保兼容性" << std::endl;
        std::cout << "----------------------------------------" << std::endl;
    
        // 启动热键监听线程
        std::thread hkThread(hotkeyListener);
    
        // 随机数生成器
        std::random_device rd;
        std::mt19937 gen(rd());
        std::uniform_int_distribution<> dis(config.minIntervalMs, config.maxIntervalMs);
    
        long long count = 0;
        while (!g_exitProgram) {
            if (g_isRunning) {
                click();
                count++;
                
                // 随机休眠
                int sleepTime = dis(gen);
                if (sleepTime < 1) sleepTime = 1;
                std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
            } else {
                std::this_thread::sleep_for(std::chrono::milliseconds(50));
            }
        }
    
        if (hkThread.joinable()) {
            hkThread.join();
        }
        
        std::cout << "程序已退出。总点击次数: " << count << std::endl;
        return 0;
    }
    
    

    Ctrl+Alt+Z暂停,Ctrl+Alt+X停止

  • 最近活动