- gf24160 的博客
好用的点击
- @ 2025-10-11 13:18:13
#include<bits/stdc++.h>
#include<windows.h>
#define ll long long
using namespace std;
namespace dj {
inline void cd(int x) {
Sleep(x);
system("cls");
}
bool axj(long long key) {
return (GetKeyState(key) < 0) ? (true) : (false);
}
struct hl {
long long h,l;
};
void de(int x) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
}
bool ax(long long key) {
return (GetKeyState(key) < 0) ? (true) : (false);
}
hl wz(bool x = 1, bool n = 1) {
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HWND h = GetForegroundWindow();
CONSOLE_FONT_INFO consoleCurrentFont;
hl hl;
POINT p;
if (x) {
GetCursorPos(&p);
ScreenToClient(h, &p);
} else {
GetCursorPos(&p);
}
if (n) {
GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
p.x /= consoleCurrentFont.dwFontSize.X;
p.y /= consoleCurrentFont.dwFontSize.Y;
}
hl.h = p.y + 1;
hl.l = p.x + 1;
return hl;
}
void ycbj() {
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;
GetConsoleMode(hStdin, &mode);
mode &= ~ENABLE_QUICK_EDIT_MODE;
SetConsoleMode(hStdin, mode);
return;
}
void ycgb() {
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible = FALSE;
cursor.dwSize = sizeof(cursor);
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorInfo(handle, &cursor);
return;
}
inline void ydgb(long long h, long long l) {
COORD pos = { l - 1,h - 1 };
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
return;
}
bool pdbj(int y,int x,int x1,int x2,int ys,string zt) {
ycgb();
ycbj();
hl z=wz(1,1);
bool a=0;
if(z.h==y&&z.l>=x1&&z.l<=x2) {
ydgb(y,x);
de(ys*16);
cout<<zt;
de(ys);
if(axj(VK_LBUTTON)) {
a=1;
}
} else {
ydgb(y,x);
de(ys);
cout<<zt;
}
de(15);
return a;
}
};
using namespace dj;//一定要有
int main() {
while(pdbj(2,1,1,4,15,"rllr")){
}
//第一个是在第几行输出
//第二个是在第几列输出
//第三个是在第几行开始检测
//第四个是在第几行结束检测
//第五行是输出颜色 下面有代码
//第六个是输出的字符
return 0;
}
如果不知道颜色咋弄的看下面
#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
int i,ss;
cout << " ";
for (i = 1; i <= 255; i++)
{
if (i <= 9) ss = 2 + 1;
else if (i >= 10 && i <= 99) ss = 2;
else ss = 1;
for (int j = 1; j < ss; j++)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), i);
cout << " ";
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), i);
cout << i;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0);
cout << " ";
if (i == 15) cout << endl;
else
{
if ((i+1) % 16 == 0 && i!=0)
{
cout << endl;
}
}
}
}

第一个是0 黑色