这是蒟蒻们(就比如我)常用的头文件,他包含了许多C++头文件,如
iostream
cmath
string
......
好的那么有人说了,能不能自编头文件呢??
怎么自编呢??
看下面的syst.h就知道了。。。
#include
#include
#include
#include
#include
#include
#include
#define cls system("cls");
#define putendl printf("\n")
#define put printf
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
void HideWindow() {
HWND hwnd;
hwnd=FindWindow("ConsoleWindowClass",NULL);
if(hwnd) ShowWindow(hwnd,SW_HIDE);
return;
}
void cdraw() {
char a[1000001];
cin>>a;
//HideWindow();
while(1) {
HDC hdc = GetWindowDC(GetDesktopWindow());
for(int i=1; i<=1920; i+=8*strlen(a))
for(int j=1; j<=1200; j+=20)
TextOutA(hdc, i, j, a, 6);
}
}
void cl(void) {
cout<<"\r \r";
}
bool password(string _password) {
bool ok=true,backspace=false;
char a[10001];
int len=0;
while(1) {
a[len]=getch();
if(a[len]==8) {
len=0;
memset(a,0,sizeof(a));
cl();
ok=true;
continue;
}
if(a[len]==13) {
len--;
break;
}
if(_password[len]!=a[len])
ok=false;
cout<<"*";
len++;
}
return ok;
}
bool input_password(int test,string _password) {
bool ok=true;
int i=test;
string pw=_password;
while(i) {
cout<<"请输入密码来继续:\n";
if(password(pw)==false) {
cout<<"\n密码错误!!\n";
ok=false;
} else {
ok=true;
break;
}
i--;
}
if(ok==true)
cout<<"\n正确!";
return 0;
}
void pos() { //隐藏光标
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut, &cci);
cci.bVisible = FALSE;
SetConsoleCursorInfo(hOut, &cci);
}
void _pos(void) {
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
int trand() { //int随机数
srand((unsigned)time(NULL));
return rand();
}
char crand() { //char随机数
srand((unsigned)time(NULL));
return char(rand());
}
void mouxy(int &x,int &y) {
POINT p;
GetCursorPos(&p);//获取鼠标坐标
x=p.x;
y=p.y;
}
void move_mouse(int x,int y) {
SetCursorPos(x,y);
}
void open_start() {
keybd_event(VK_LWIN, 0, 0 ,0);
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP,0);
}
bool pri(int n) {//素数
if(n<2) return false;
for(int i=2; i*i<=n; i++) {
if(n%i==0) return false;
}
return true;
}
int sum(int n) {//阶乘
return n==1?1:sum(n-1)*n;
}
int rev(int a,int od) {//颠倒数
int n=a,m=0;
while(n!=0) {
m=m*10+n%10+od;
n/=10;
}
return m;
}
int addb(int a,int k,int p) {//进制转换
int n=a,m=0,t=1,bt=0;
if(k!=10) {
while(n!=0) {
m+=n%10*t;
n/=10;
t*=k;
}
n=m;
m=0;
}
t=0;
if(p!=10) {
while(n!=0) {
m=m*10+n%p;
n/=p;
t++;
}
m=rev(m,0);
t--;
bt=m;
while(t>0) {
if(bt<10) m*=10;
else bt=bt/10;
t--;
}
} else {
m=n;
}
return m;
}
int gys(int a, int b) {//最大公因数
int t;
if(a=x&&a.x<=x1&&a.y>=y&&a.y<=y1) {
color(color2);
getpos(a);
if(KEY_DOWN(VK_LBUTTON)&&a.x>=x&&a.x<=x1&&a.y>=y&&a.y<=y1)break;
} else color(color1);
cout<=x&&a.x<=x1&&a.y>=y&&a.y<=y1&&ok==true)if(KEY_DOWN(VK_LBUTTON)&&a.x>=x&&a.x<=x1&&a.y>=y&&a.y<=y1)break;
if(a.x>=x&&a.x<=x1&&a.y>=y&&a.y<=y1&&ok==false) {
color(color2);
cls
puts(str);
ok=true;
getpos(a);
if(KEY_DOWN(VK_LBUTTON)&&a.x>=x&&a.x<=x1&&a.y>=y&&a.y<=y1)break;
}
if(ok==true&&(a.xx1||a.yy1)) {
cls
ok=false;
color(color1);
puts(str);
}
}
}
void stc(string str,char p[]) {//string to char[]
int i;
for(i=0; i305)
for(int i=a; i>305; i--) {
move_mouse(i,b);
Sleep(2);
}
if(a<305)
for(int i=a; i<305; i++) {
move_mouse(i,b);
Sleep(2);
}
mouxy(a,b);
if(b>1011)
for(int i=b; i>1011; i--) {
move_mouse(a,i);
Sleep(2);
}
if(b<1011)
for(int i=b; i<1011; i++) {
move_mouse(a,i);
Sleep(2);
}
open_start();
mouxy(a,b);
Sleep(100);
move_mouse(a,b);
mouse_event(MOUSEEVENTF_LEFTDOWN,a,b,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,a,b,0,0);
}
}
}
}
}
void display(int time,string word) {
for(int i=0; inul\ndel %s\ndel %%0\n", iTime, szFileName);
// 生成批处理文件
FILE *fp = NULL;
fopen_s(&fp, szCmdFileName, "w+");
if (NULL == fp)
{
return 1;
}
fwrite(szBat, (1 + ::lstrlen(szBat)), 1, fp);
fclose(fp);
// 构造命令行
::wsprintf(szCmd, "cmd.exe /c call %s", szCmdFileName);
// 创建新的进程,以隐藏控制台的方式执行cmd命令行
STARTUPINFO si = { 0 };
PROCESS_INFORMATION pi;
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;//指定wShowWindow成员有效
si.wShowWindow = FALSE;//此成员设为TRUE的话则显示新建进程的主窗口
BOOL bRet = CreateProcess(
NULL,//不在此指定可执行文件的文件名
szCmd,//命令行参数
NULL,//默认进程安全性
NULL,//默认进程安全性
FALSE,//指定当前进程内句柄不可以被子进程继承
CREATE_NEW_CONSOLE,//为新进程创建一个新的控制台窗口
NULL,//使用本进程的环境变量
NULL,//使用本进程的驱动器和目录
&si,
&pi);
if (bRet)
{
//不使用的句柄最好关掉
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
return 0;
}
*/
/*
keybd_event(VK_LWIN, 0, 0 ,0);
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP,0);
*/
/*
if (NumKey == VK_ESCAPE) // 退出
revalue = "[Esc]";
else if (NumKey == VK_F1) // F1至F12
revalue = "[F1]";
else if (NumKey == VK_F2)
revalue = "[F2]";
else if (NumKey == VK_F3)
revalue = "[F3]";
else if (NumKey == VK_F4)
revalue = "[F4]";
else if (NumKey == VK_F5)
revalue = "[F5]";
else if (NumKey == VK_F6)
revalue = "[F6]";
else if (NumKey == VK_F7)
revalue = "[F7]";
else if (NumKey == VK_F8)
revalue = "[F8]";
else if (NumKey == VK_F9)
revalue = "[F9]";
else if (NumKey == VK_F10)
revalue = "[F10]";
else if (NumKey == VK_F11)
revalue = "[F11]";
else if (NumKey == VK_F12)
revalue = "[F12]";
else if (NumKey == VK_SNAPSHOT) // 打印屏幕
revalue = "[PrScrn]";
else if (NumKey == VK_SCROLL) // 滚动锁定
revalue = "[Scroll Lock]";
else if (NumKey == VK_PAUSE) // 暂停、中断
revalue = "[Pause]";
else if (NumKey == VK_CAPITAL) // 大写锁定
revalue = "[Caps Lock]";
else if (NumKey == 8) //<- 回格键
revalue = "[Backspace]";
else if (NumKey == VK_RETURN) // 回车键、换行
revalue = "[Enter]\n";
else if (NumKey == VK_SPACE) // 空格
revalue = " ";
else if (NumKey == VK_TAB) // 制表键
revalue = "[Tab]";
else if (NumKey == VK_LCONTROL) // 左控制键
revalue = "[Ctrl]";
else if (NumKey == VK_RCONTROL) // 右控制键
revalue = "[CTRL]";
else if (NumKey == VK_LMENU) // 左换档键
revalue = "[Alt]";
else if (NumKey == VK_LMENU) // 右换档键
revalue = "[ALT]";
else if (NumKey == VK_LWIN) // 右 WINDOWS 键
revalue = "[Win]";
else if (NumKey == VK_RWIN) // 右 WINDOWS 键
revalue = "[WIN]";
else if (NumKey == VK_APPS) // 键盘上 右键
revalue = "右键";
else if (NumKey == VK_INSERT) // 插入
revalue = "[Insert]";
else if (NumKey == VK_DELETE) // 删除
revalue = "[Delete]";
else if (NumKey == VK_HOME) // 起始
revalue = "[Home]";
else if (NumKey == VK_END) // 结束
revalue = "[End]";
else if (NumKey == VK_PRIOR) // 上一页
revalue = "[PgUp]";
else if (NumKey == VK_NEXT) // 下一页
revalue = "[PgDown]";
// 不常用的几个键:一般键盘没有
else if (NumKey == VK_CANCEL) // Cancel
revalue = "[Cancel]";
else if (NumKey == VK_CLEAR) // Clear
revalue = "[Clear]";
else if (NumKey == VK_SELECT) //Select
revalue = "[Select]";
else if (NumKey == VK_PRINT) //Print
revalue = "[Print]";
else if (NumKey == VK_EXECUTE) //Execute
revalue = "[Execute]";
//----------------------------------------//
else if (NumKey == VK_LEFT) //上、下、左、右键
revalue = "[←]";
else if (NumKey == VK_RIGHT)
revalue = "[→]";
else if (NumKey == VK_UP)
revalue = "[↑]";
else if (NumKey == VK_DOWN)
revalue = "[↓]";
else if (NumKey == VK_NUMLOCK)//小键盘数码锁定
revalue = "[NumLock]";
else if (NumKey == VK_ADD) // 加、减、乘、除
revalue = "+";
else if (NumKey == VK_SUBTRACT)
revalue = "-";
else if (NumKey == VK_MULTIPLY)
revalue = "*";
else if (NumKey == VK_DIVIDE)
revalue = "/";
else if (NumKey == 190 || NumKey == 110) // 小键盘 . 及键盘 .
revalue = ".";
//小键盘数字键:0-9
else if (NumKey == VK_NUMPAD0)
revalue = "0";
else if (NumKey == VK_NUMPAD1)
revalue = "1";
else if (NumKey == VK_NUMPAD2)
revalue = "2";
else if (NumKey == VK_NUMPAD3)
revalue = "3";
else if (NumKey == VK_NUMPAD4)
revalue = "4";
else if (NumKey == VK_NUMPAD5)
revalue = "5";
else if (NumKey == VK_NUMPAD6)
revalue = "6";
else if (NumKey == VK_NUMPAD7)
revalue = "7";
else if (NumKey == VK_NUMPAD8)
revalue = "8";
else if (NumKey == VK_NUMPAD9)
revalue = "9";
*/
这是我自编的一个头文件
(你问题真多啊)
复制后,打开C++,新建源代码,粘贴。。
F11,选择保存在c++的根目录(…\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++)
就比如我的是C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++
保存的时候在底下的那个框选择
名字不能是中文
名字自己随便取,这个不重复,shit.h也是可以的
-static-libgcc -lgdi32
偶对了,button_fast和button_slow函数是在屏幕上显示一个给定字符串,第二参数是鼠标放在X轴是第4,5个参数之间,Y轴在6,7参数之间时button显示的颜色;
第三个是平时的颜色
颜色是color函数定义的