前言
这几天真是热得要发财,不是38度就是42度,难~受~
不过,虽说天气热,但是还是要工作TAT
。。。。。。
最近做游戏,又发现了几个Maker_Game/Console的漏洞:
- 进程的函数用不了,漏洞多
- 正如荒岛往事所说:SlowSay()在特定情况下无法使用。
- 没有Make_Text,并且需要ReadFile
- ......
正文
开始改!
1、进程
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_TRAYICON:
// 处理托盘图标事件
switch (LOWORD(lParam)) {
case WM_RBUTTONUP: {
// 创建右键菜单
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, 1, "打开");
AppendMenu(hMenu, MF_STRING, 2, "退出");
// 获取鼠标位置
POINT pt;
GetCursorPos(&pt);
// 显示菜单
SetForegroundWindow(hwnd);
TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL);
DestroyMenu(hMenu);
break;
}
case WM_LBUTTONDBLCLK:
break;
}
return 0;
case WM_COMMAND:
// 处理菜单项点击
switch (LOWORD(wParam)) {
case 1:
//MessageBox(hwnd, "打开功能已触发!", "提示", MB_OK);
break;
case 2:
// 退出程序前移除托盘图标
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.hIcon = NULL,
.szTip = {0},
.dwState = 0,
.dwStateMask = 0,
.szInfo = {0},
.uTimeout = 0,
.szInfoTitle = {0},
.dwInfoFlags = 0
};
Shell_NotifyIcon(NIM_DELETE, &nid);
PostQuitMessage(0);
break;
}
return 0;
case WM_DESTROY:
// 窗口销毁时移除托盘图标
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.hIcon = NULL,
.szTip = {0},
.dwState = 0,
.dwStateMask = 0,
.szInfo = {0},
.uTimeout = 0,
.szInfoTitle = {0},
.dwInfoFlags = 0
};
Shell_NotifyIcon(NIM_DELETE, &nid);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
// 在托盘创建图标的函数
bool CreateSystemTrayIcon(HWND hwnd, const std::string& tooltip) {
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.szTip = {0}
};
// 加载图标
HICON hIcon = (HICON)LoadImage(NULL, "Opener.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
if (!hIcon) {
DWORD error = GetLastError();
char buffer[256];
sprintf(buffer, "图标加载失败!错误代码: %lu", error);
MessageBox(hwnd, buffer, "错误", MB_ICONERROR);
hIcon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_SHARED);
}
nid.hIcon = hIcon;
strncpy(nid.szTip, tooltip.c_str(), sizeof(nid.szTip) - 1);
// 添加托盘图标并返回结果
return Shell_NotifyIcon(NIM_ADD, &nid) != FALSE;
}
POINT Windowpos() {
POINT p;
GetCursorPos(&p);
HWND h = GetForegroundWindow();
ScreenToClient(h, &p);
p.x /= 8;
p.y /= 16;
return p;
}
void color(int a) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), a);
}
FUNCTION HideCursor() {
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);// ? ? ?
CursorInfo.bVisible = false; // ? ?
SetConsoleCursorInfo(handle, &CursorInfo);// ? ? ??
}
FUNCTION scolor(int ForgC, int BackC) {
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
FUNCTION syscolor(char colors[5]) {
char t[100];
sprintf(t, "color %s", colors);
system(t);
}
// 检查进程是否运行
bool IsProcessRunning(const std::string& processName) {
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapshot == INVALID_HANDLE_VALUE) {
return false;
}
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hSnapshot, &pe32)) {
CloseHandle(hSnapshot);
return false;
}
bool found = false;
do {
std::string currentProcess = pe32.szExeFile;
for (char& c : currentProcess) {
c = std::tolower(c);
}
std::string targetProcess = processName;
for (char& c : targetProcess) {
c = std::tolower(c);
}
if (currentProcess.find(targetProcess) != std::string::npos) {
found = true;
break;
}
} while (Process32Next(hSnapshot, &pe32));
CloseHandle(hSnapshot);
return found;
}
// 窗口过程函数
LRESULT CALLBACK WindowProcess(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_TRAYICON:
switch (LOWORD(lParam)) {
case WM_RBUTTONUP: {
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, 1, "打开");
AppendMenu(hMenu, MF_STRING, 2, "退出");
POINT pt;
GetCursorPos(&pt);
SetForegroundWindow(hwnd);
TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL);
DestroyMenu(hMenu);
break;
}
case WM_LBUTTONDBLCLK:
if(IsProcessRunning("main.exe") == 0)
system("start main.exe");
break;
}
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case 1:
if(IsProcessRunning("main.exe") == 0)
system("start main.exe");
break;
case 2:
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.hIcon = NULL,
.szTip = {0}
};
Shell_NotifyIcon(NIM_DELETE, &nid);
PostQuitMessage(0);
break;
}
return 0;
case WM_DESTROY:
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.hIcon = NULL,
.szTip = {0}
};
Shell_NotifyIcon(NIM_DELETE, &nid);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
// 创建系统托盘图标
bool CreateSystemTrayIcons(HWND hwnd, const std::string& tooltip) {
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.szTip = {0}
};
HICON hIcon = (HICON)LoadImage(NULL, "Opener.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
if (!hIcon) {
DWORD error = GetLastError();
char buffer[256];
sprintf(buffer, "图标加载失败!错误代码: %lu", error);
MessageBox(hwnd, buffer, "错误", MB_ICONERROR);
hIcon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_SHARED);
}
nid.hIcon = hIcon;
strncpy(nid.szTip, tooltip.c_str(), sizeof(nid.szTip) - 1);
return Shell_NotifyIcon(NIM_ADD, &nid) != FALSE;
}
// 托盘应用主函数(可被外部调用)
int RunTrayApplication(string s,HINSTANCE hInstance) {
// 启动目标程序
system("start main.exe");
// 注册窗口类
WNDCLASS wc = {
.style = 0,
.lpfnWndProc = WindowProc,
.cbClsExtra = 0,
.cbWndExtra = 0,
.hInstance = hInstance,
.hIcon = NULL,
.hCursor = LoadCursor(NULL, IDC_ARROW),
.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1),
.lpszMenuName = NULL,
.lpszClassName = "TrayAppClass"
};
if (!RegisterClass(&wc)) {
return 1;
}
// 创建隐藏窗口
HWND hwnd = CreateWindow(wc.lpszClassName, "Tray Application",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, NULL, NULL, hInstance, NULL);
if (!hwnd) {
return 1;
}
// 创建托盘图标
if (!CreateSystemTrayIcon(hwnd, s)) {
MessageBox(hwnd, "创建托盘图标失败!", "错误", MB_ICONERROR);
return 1;
}
// 隐藏窗口
ShowWindow(hwnd, SW_HIDE);
// 消息循环
MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
2、SlowSay
struct outtext {
char text[100000];
int t;
};
void SlowSay(outtext tet) {
for (int i = 0; i <= strlen(tet.text) - 1; i++) {
Beep(3000, 20);
printf("%c", tet.text[i]);
_sleep(tet.t);
}
}
3、Make_Text和ReadFile
void Make_Text(string same, string name) {
ofstream outfile(same, ios::out);
if (!outfile) {
cerr << "open error" << endl;
}
outfile << name;
outfile.close();
}
string ReadFile(const string& filename) {
ifstream infile(filename);
if (!infile) {
cerr << "read error" << std::endl;
return "";
}
string content((std::istreambuf_iterator<char>(infile)),
std::istreambuf_iterator<char>());
infile.close();
return content;
}
完整代码
#ifndef MAKER_CONSOLE_H
#include <bits/stdc++.h>
#include <ctime>
#include <time.h>
#include <windows.h>
#include <Button.h>
#include <lm.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <tchar.h>
#include <ArtText.h>
#include <windows.h>
#include <shellapi.h>
#include <string>
#include <cstring>
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#include <string>
using namespace std;
namespace console_game {
// 禁用安全函数警告(若编译器支持)
#define _CRT_SECURE_NO_WARNINGS
// 定义托盘图标消息
#define WM_TRAYICON (WM_USER + 1)
enum Click {
#define Down 80
#define Up 72
#define Left 75
#define Right 77
#define Space 32
};
#define FUNCTION inline void
#define iv inline void
#define ii inline int
#define ib inline bool
#define is string
BOOL isFileExists(string name) {
ifstream f(name.c_str(), ios::in);
return f.good();
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_TRAYICON:
// 处理托盘图标事件
switch (LOWORD(lParam)) {
case WM_RBUTTONUP: {
// 创建右键菜单
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, 1, "打开");
AppendMenu(hMenu, MF_STRING, 2, "退出");
// 获取鼠标位置
POINT pt;
GetCursorPos(&pt);
// 显示菜单
SetForegroundWindow(hwnd);
TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL);
DestroyMenu(hMenu);
break;
}
case WM_LBUTTONDBLCLK:
break;
}
return 0;
case WM_COMMAND:
// 处理菜单项点击
switch (LOWORD(wParam)) {
case 1:
//MessageBox(hwnd, "打开功能已触发!", "提示", MB_OK);
break;
case 2:
// 退出程序前移除托盘图标
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.hIcon = NULL,
.szTip = {0},
.dwState = 0,
.dwStateMask = 0,
.szInfo = {0},
.uTimeout = 0,
.szInfoTitle = {0},
.dwInfoFlags = 0
};
Shell_NotifyIcon(NIM_DELETE, &nid);
PostQuitMessage(0);
break;
}
return 0;
case WM_DESTROY:
// 窗口销毁时移除托盘图标
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.hIcon = NULL,
.szTip = {0},
.dwState = 0,
.dwStateMask = 0,
.szInfo = {0},
.uTimeout = 0,
.szInfoTitle = {0},
.dwInfoFlags = 0
};
Shell_NotifyIcon(NIM_DELETE, &nid);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
// 在托盘创建图标的函数
bool CreateSystemTrayIcon(HWND hwnd, const std::string& tooltip) {
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.szTip = {0}
};
// 加载图标
HICON hIcon = (HICON)LoadImage(NULL, "Opener.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
if (!hIcon) {
DWORD error = GetLastError();
char buffer[256];
sprintf(buffer, "图标加载失败!错误代码: %lu", error);
MessageBox(hwnd, buffer, "错误", MB_ICONERROR);
hIcon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_SHARED);
}
nid.hIcon = hIcon;
strncpy(nid.szTip, tooltip.c_str(), sizeof(nid.szTip) - 1);
// 添加托盘图标并返回结果
return Shell_NotifyIcon(NIM_ADD, &nid) != FALSE;
}
POINT Windowpos() {
POINT p;
GetCursorPos(&p);
HWND h = GetForegroundWindow();
ScreenToClient(h, &p);
p.x /= 8;
p.y /= 16;
return p;
}
void color(int a) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), a);
}
FUNCTION HideCursor() {
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);// ? ? ?
CursorInfo.bVisible = false; // ? ?
SetConsoleCursorInfo(handle, &CursorInfo);// ? ? ??
}
FUNCTION scolor(int ForgC, int BackC) {
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
FUNCTION syscolor(char colors[5]) {
char t[100];
sprintf(t, "color %s", colors);
system(t);
}
// 检查进程是否运行
bool IsProcessRunning(const std::string& processName) {
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapshot == INVALID_HANDLE_VALUE) {
return false;
}
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hSnapshot, &pe32)) {
CloseHandle(hSnapshot);
return false;
}
bool found = false;
do {
std::string currentProcess = pe32.szExeFile;
for (char& c : currentProcess) {
c = std::tolower(c);
}
std::string targetProcess = processName;
for (char& c : targetProcess) {
c = std::tolower(c);
}
if (currentProcess.find(targetProcess) != std::string::npos) {
found = true;
break;
}
} while (Process32Next(hSnapshot, &pe32));
CloseHandle(hSnapshot);
return found;
}
// 窗口过程函数
LRESULT CALLBACK WindowProcess(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_TRAYICON:
switch (LOWORD(lParam)) {
case WM_RBUTTONUP: {
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, 1, "打开");
AppendMenu(hMenu, MF_STRING, 2, "退出");
POINT pt;
GetCursorPos(&pt);
SetForegroundWindow(hwnd);
TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL);
DestroyMenu(hMenu);
break;
}
case WM_LBUTTONDBLCLK:
if(IsProcessRunning("main.exe") == 0)
system("start main.exe");
break;
}
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case 1:
if(IsProcessRunning("main.exe") == 0)
system("start main.exe");
break;
case 2:
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.hIcon = NULL,
.szTip = {0}
};
Shell_NotifyIcon(NIM_DELETE, &nid);
PostQuitMessage(0);
break;
}
return 0;
case WM_DESTROY:
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.hIcon = NULL,
.szTip = {0}
};
Shell_NotifyIcon(NIM_DELETE, &nid);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
// 创建系统托盘图标
bool CreateSystemTrayIcons(HWND hwnd, const std::string& tooltip) {
NOTIFYICONDATA nid = {
.cbSize = sizeof(NOTIFYICONDATA),
.hWnd = hwnd,
.uID = 1,
.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP,
.uCallbackMessage = WM_TRAYICON,
.szTip = {0}
};
HICON hIcon = (HICON)LoadImage(NULL, "Opener.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
if (!hIcon) {
DWORD error = GetLastError();
char buffer[256];
sprintf(buffer, "图标加载失败!错误代码: %lu", error);
MessageBox(hwnd, buffer, "错误", MB_ICONERROR);
hIcon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_SHARED);
}
nid.hIcon = hIcon;
strncpy(nid.szTip, tooltip.c_str(), sizeof(nid.szTip) - 1);
return Shell_NotifyIcon(NIM_ADD, &nid) != FALSE;
}
// 托盘应用主函数(可被外部调用)
int RunTrayApplication(string s,HINSTANCE hInstance) {
// 启动目标程序
system("start main.exe");
// 注册窗口类
WNDCLASS wc = {
.style = 0,
.lpfnWndProc = WindowProc,
.cbClsExtra = 0,
.cbWndExtra = 0,
.hInstance = hInstance,
.hIcon = NULL,
.hCursor = LoadCursor(NULL, IDC_ARROW),
.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1),
.lpszMenuName = NULL,
.lpszClassName = "TrayAppClass"
};
if (!RegisterClass(&wc)) {
return 1;
}
// 创建隐藏窗口
HWND hwnd = CreateWindow(wc.lpszClassName, "Tray Application",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, NULL, NULL, hInstance, NULL);
if (!hwnd) {
return 1;
}
// 创建托盘图标
if (!CreateSystemTrayIcon(hwnd, s)) {
MessageBox(hwnd, "创建托盘图标失败!", "错误", MB_ICONERROR);
return 1;
}
// 隐藏窗口
ShowWindow(hwnd, SW_HIDE);
// 消息循环
MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
void Full_screen() {
HWND hwnd = GetForegroundWindow();
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
LONG l_WinStyle = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE,
(l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME &
~WS_BORDER);
SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
}
FUNCTION StartFile(char filename[100]) {
char t[200];
sprintf(t, "start %s", filename);
system(t);
}
void Make_Text(string same, string name) {
ofstream outfile(same, ios::out);
if (!outfile) {
cerr << "open error" << endl;
}
outfile << name;
outfile.close();
}
string ReadFile(const string& filename) {
ifstream infile(filename);
if (!infile) {
cerr << "read error" << std::endl;
return "";
}
string content((std::istreambuf_iterator<char>(infile)),
std::istreambuf_iterator<char>());
infile.close();
return content;
}
VOID KillConsoleCloseButton(VOID) {
DeleteMenu(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_DISABLED);
DrawMenuBar(GetConsoleWindow());
}
VOID OpenConsoleCloseButton(VOID) {
DeleteMenu(GetSystemMenu(GetConsoleWindow(), TRUE), SC_CLOSE, MF_DISABLED);
DrawMenuBar(GetConsoleWindow());
}
FUNCTION Pause() {
system("pause");
}
FUNCTION Cls() {
system("cls");
}
FUNCTION ModeWindow(int cols, int lines) {
char t[1000];
sprintf(t, "mode con cols=%d lines=%d", cols, lines);
system(t);
}
FUNCTION gotoxy(int x, int y) {
COORD Pos;
Pos.X = y;
Pos.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
int mouse;
POINT p;
FUNCTION GetMouse() {
mouse = GetAsyncKeyState(VK_LBUTTON) & 0x8000;
p = Windowpos();
}
bool IsMouse(int x1, int y1, int x2, int y2) {
if (p.x >= x2 && p.y >= y1 && p.x <= x1 && p.y <= y2)
return true;
else
return false;
}
bool IsMouseClick() {
if (mouse)
return true;
else
return false;
}
void PrintSpace(int H, int L) {
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= L; j++)
cout << " ";
cout << endl;
}
}
struct button {
string name;
string b[100];
int bnum;
};
int nowway = 0;
bool up[100] = { true, false, false };
bool down[100] = { true, false, false };
string outbutton(button way[]) {
char c;
int now = 0;
for (int i = 0; i < 100; i++) {
if (down[i] == true) {
now = i;
}
}
while (1) {
system("cls");
for (int i = 0; way[i].name != ""; i++) {
if (up[i] == true) {
color(240);
cout << "|" << way[i].name << "|";
color(15);
} else {
color(15);
cout << " " << way[i].name << " ";
}
}
printf("\n");
cout << endl;
for (int i = 0; way[nowway].b[i] != ""; i++) {
if (down[i] == true) {
color(127);
cout << " " << way[nowway].b[i] << " " << endl;
color(15);
} else {
color(15);
cout << " " << way[nowway].b[i] << " " << endl;
}
}
c = getch();
if ((c == 'w' || c == Up || c == '8') && now > 0) {
gotoxy(0, 0);
down[now] = false;
down[now - 1] = true;
now -= 1;
}
if ((c == 's' || c == Down || c == '2') && way[nowway].b[now + 1] != "") {
gotoxy(0, 0);
down[now] = false;
down[now + 1] = true;
now += 1;
}
if ((c == 'a' || c == Left || c == '4') && nowway > 0) {
gotoxy(0, 0);
now = 0;
down[1] = true;
for (int i = 0; way[nowway].b[i] != ""; i++) {
if (down[i] == true) {
color(127);
cout << " " << way[nowway].b[i] << " " << endl;
color(15);
} else {
color(15);
cout << " " << way[nowway].b[i] << " " << endl;
}
}
up[nowway] = false;
up[nowway - 1] = true;
nowway -= 1;
down[now] = false;
down[0] = true;
down[1] = false;
down[2] = false;
down[3] = false;
down[4] = false;
down[5] = false;
}
if ((c == 'd' || c == Right || c == '6') && way[nowway + 1].name != "") {
gotoxy(0, 0);
now = 0;
for (int i = 0; way[nowway].b[i] != ""; i++) {
if (down[i] == true) {
color(127);
cout << " " << way[nowway].b[i] << " " << endl;
color(15);
} else {
color(15);
cout << " " << way[nowway].b[i] << " " << endl;
}
}
up[nowway] = false;
up[nowway + 1] = true;
nowway += 1;
down[now] = false;
down[0] = true;
down[1] = false;
down[2] = false;
down[3] = false;
down[4] = false;
down[5] = false;
}
if (c == 32) {
return way[nowway].b[now];
}
}
return "";
}
struct outtext {
char text[100000];
int t;
};
void SlowSay(outtext tet) {
for (int i = 0; i <= strlen(tet.text) - 1; i++) {
Beep(3000, 20);
printf("%c", tet.text[i]);
_sleep(tet.t);
}
}
//调试程序,用不了:)
FUNCTION AboutConsoleGame()
{
Button english = NewButton(3, 1, 15, "1.English");
Button chinese = NewButton(3, 18, 15, "2. ");
int Language = 1;
Cls();
syscolor("0e");
printf("Welcome To The \"ABOUT THE CONSOLE GAME\"!!!\n");
_sleep(200);
syscolor("0f");
printf("Please Select Your Language:\n");
while(1)
{
if(Preserve(english) == 1 || -32767 == GetAsyncKeyState('1'))
{
Language = 1;
break;
}
if(Preserve(chinese) == 1 || -32767 == GetAsyncKeyState('2'))
{
Language = 2;
break;
}
}
if(Language == 2)
{
printf(" \n\n");
_sleep(200);
syscolor("0e");
printf("ii ib is iv ? ");
syscolor("0a");
printf("inline int inline bool string inline void \n\n");
}
}
}
#endif
使用须知
这个头文件需要放到Dev Cpp / MinGW32 / include,在里面新建一个文件夹,叫做Maker_Game,把刚刚这个文件保存在这个文件夹里面,叫Console。
可以点赞收藏加关注嘛QAQ
按下Ctrl+D有惊喜呀!