一个连点器qwq

· · 个人记录

一个连点器qwq

#include<Windows.h>
#include<iostream>
#include<chrono>
#include<thread>
#include<random>
namespace my{
    template <typename _Tp = double, typename _Clock = std::chrono::steady_clock>
    class timer{
private:
        typedef typename std::chrono::duration<_Tp, std::ratio<1, 1> > _Dur;
        typedef typename std::chrono::time_point<_Clock, _Dur> _Point;
        int _cnt;
        _Point _start_time;
public:
        timer() : _cnt(0), _start_time(_Clock::now()) { }
        void start() { ++_cnt; _start_time = _Clock::now(); return ; }
        _Tp duration() { _Point _end_time(_Clock::now()); return (_end_time - _start_time).count(); }
        int count() { return _cnt; }
    };
}
my::timer<> timer;
volatile int state;
void show_fun(){
    int old_state=-84584;
    while(1){
        if(state!=old_state){
            old_state=state;
            system("cls");
            if(state==0){
                system("color 07");
                std::cout<<"Sleaping..."<<std::flush;
            }else if(state==1){
                system("color 70");
                std::cout<<"Cheating!!!"<<std::flush;
            }else if(state==2){
                system("color 70");
                std::cout<<"Waiting..."<<std::flush;
            }
        }
    }
    return ;
}
void cheat_fun(){
    std::mt19937 mt(666667);
    std::uniform_real_distribution<> u(0.05,0.09);
    double tim=0;
    while(1){
        if(state==1){
            if(tim<=timer.duration()){
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
tim=timer.duration()+u(mt);
            }
        }
    }
    return ;
}
bool check_key_down(int button){
    return GetAsyncKeyState(button) & 0x8000 ? true : false;
}
void solve(){
    int mstate=0;
    while(1){
        if(mstate==0){
            if(check_key_down('M')){
                mstate=1;
                if(state==0){
                    state=2;
                }else{
                    state=0;
                }
            }
        }else{
            if(!check_key_down('M')){
                mstate=0;
            }
        }
        if(state==2){
            if(check_key_down(VK_RBUTTON)) state=1;
        }
        if(state==1){
            if(!check_key_down(VK_RBUTTON)) state=2;
        }
    }
    return ;
}
int main(){
    SetWindowPos(GetForegroundWindow(), HWND_BOTTOM, 0, 0, 400, 200, SWP_NOZORDER | SWP_NOMOVE);
    // set size
    SetWindowPos(GetForegroundWindow(), HWND_BOTTOM, 1, 1, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
    // set pos
    SetWindowPos(GetForegroundWindow(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    // set it to top
    SetConsoleTitle("mice cheater qwq");
    state = 0;
    std::thread show_th(show_fun),cheat_th(cheat_fun);
    show_th.detach();
    cheat_th.detach();
    solve();
    return 0;
}