欢迎光临散文网 会员登陆 & 注册

使用c++在愚人节这天在不投降的情况下使用PCL2启动游戏!

2023-04-02 00:03 作者:Perry6632  | 我要投稿

知周所众 PCL2 有一个愚人节菜单,只要你鼠标移到启动游戏按键时,它就会飞走,所以,你只能点击投降键来认输,会让我们颜面尽失

最为一名会c++的且用PCL2的人,我有义务去为害民除帮玩家解决这一个难题

所以,我写出了它:


它可以检测PCL2的状态,并在不投降的情况下开始游戏

注意:按下ecs键即可开启游戏,但是要确保开始游戏的按键在原位且PCL2在初始位置,没有移动过位置

代码如下:

#include<bits/stdc++.h>
#include<windows.h>
#include<tlhelp32.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define setcolor(int) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),int)
using namespace std;
void Mouse_Move(int x, int y){
    double fScreenWidth = ::GetSystemMetrics(SM_CXSCREEN) - 1;
    double fScreenHeight = ::GetSystemMetrics(SM_CYSCREEN) - 1;
    double fx = x * (65535.0f / fScreenWidth);
    double fy = y * (65535.0f / fScreenHeight);
    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, fx, fy, 0, 0);
}
void gbc(BOOL a){
    HANDLE gb =GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO cursor_info;
    GetConsoleCursorInfo(gb,&cursor_info);
    cursor_info.bVisible=a;
    SetConsoleCursorInfo(gb,&cursor_info);
}
void move( int  x ,  int  y ){    
    COORD  point = {  x ,  y  }; 
    HANDLE  HOutput = GetStdHandle( STD_OUTPUT_HANDLE ); 
    SetConsoleCursorPosition(HOutput, point); 
}
bool jc(const char* ch){
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    if (INVALID_HANDLE_VALUE == hSnapshot)
        return 0;
    PROCESSENTRY32 pi; 
    pi.dwSize = sizeof(PROCESSENTRY32);
    BOOL bRet = Process32First(hSnapshot,&pi);
    while (bRet){   
        const char* szf=pi.szExeFile;
        if(strcmp(szf,ch)==0)return 1;
        bRet = Process32Next(hSnapshot,&pi);
    }
    return 0;
}
typedef struct{
    HWND hwndWindow;
    DWORD dwProcessID;
}EnumWindowsArg;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam){
    EnumWindowsArg *pArg = (EnumWindowsArg *)lParam;
    DWORD dwProcessID = 0;
    ::GetWindowThreadProcessId(hwnd, &dwProcessID);
    if (dwProcessID == pArg->dwProcessID){
        pArg->hwndWindow = hwnd;
        return FALSE;
    }
    return TRUE;
}
HWND GetWindowHwndByPID(DWORD dwProcessID){
    HWND hwndRet = NULL;
    EnumWindowsArg ewa;
    ewa.dwProcessID = dwProcessID;
    ewa.hwndWindow = NULL;
    EnumWindows(EnumWindowsProc, (LPARAM)&ewa);
    if (ewa.hwndWindow)
        hwndRet = ewa.hwndWindow;
    return hwndRet;
}
int main(){
    POINT p;
    SetConsoleTitle("暴打PCL2愚人节");
    system("mode con cols=35 lines=5");
    while(1){
        time_t now = time(NULL);
        tm* tm_t = localtime(&now);
        gbc(0);
        move(0,0);
        setcolor(15);
        cout<<"[PCL游戏启动辅助器]"<<endl;
        setcolor(14);
        cout<<"用PCL启动游戏(esc)"<<endl;
        setcolor(7);
        if(jc("PCL2.exe"))cout<<"检测到PCL2"<<endl;
        else cout<<"未检测到PCL2"<<endl;
        setcolor(8);
        stringstream ss;
        ss << "当前时间:" << tm_t->tm_year + 1900 << "." << tm_t->tm_mon + 1 << "." << tm_t->tm_mday<< "." << tm_t->tm_hour << "." << tm_t->tm_min<<"."<<tm_t->tm_sec;
        cout<<ss.str();
        if(KEY_DOWN(VK_ESCAPE)){
            Mouse_Move(598,178);
            mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
            mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
            Mouse_Move(540,570);
            mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
            mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
            while(KEY_DOWN(VK_SPACE));
        }
    }
}

代码共94行2878字


看完后不妨留下你的三连+关注

我是Perry6632,bey~

使用c++在愚人节这天在不投降的情况下使用PCL2启动游戏!的评论 (共 条)

分享到微博请遵守国家法律