#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include <assert.h>
#include <tchar.h>
#define Key_Down(VK_NONAME) ((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
//#define Sleep(x) Sleep(x/15)
//#define Sleep(x) Sleep(x/2)
using namespace std;
//位置结构体
CONSOLE_SCREEN_BUFFER_INFO weizi;
//光标结构体
CONSOLE_CURSOR_INFO kzgqx;
//鼠标结构体
CONSOLE_FONT_INFO console;
//获取控制台
HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
//窗口信息
HWND hw=GetForegroundWindow();
POINT p;
struct HH{
int X,Y;
}post;
void Window(int x,int y){//窗口大小
SMALL_RECT rc={1,1,x,y};
//重置窗口位置和大小
GetConsoleScreenBufferInfo(handle,&weizi);
//获取窗口缓冲区信息
SetConsoleWindowInfo(handle,1,&rc);
}
void Wind(int x,int y){//缓冲区大小
COORD size={x,y};
//位置结构体
GetConsoleScreenBufferInfo(handle,&weizi);
//获取窗口缓冲区信息
SetConsoleScreenBufferSize(handle,size);
//重新设置缓冲区大小
}
void Cursorj(bool x){//光标见
GetConsoleCursorInfo(handle,&kzgqx);
//获取控制台光标信息
kzgqx.bVisible=x;
//隐藏开启控制台光标
SetConsoleCursorInfo(handle,&kzgqx);
}
void Cursorw(){//光标位
GetConsoleScreenBufferInfo(handle,&weizi);
//获取光标位置
post.X=weizi.dwCursorPosition.X;
post.Y=weizi.dwCursorPosition.Y;
}
inline void Cursorg(int x,int y){//光标改
COORD size={x,y};
SetConsoleCursorPosition(handle,size);
}
inline void Color(int x){//字符背景颜色
SetConsoleTextAttribute(handle,x);}
char a[5][250];
int len[5],pt=0;
bool flag=0;
void test(){
Cursorj(0);flag=1;
Cursorg(24,18);
Color(12);printf("登录中...");
Sleep(2000);
system("cls");
Cursorg(24,12);printf("登录成功!");
Sleep(2000);Color(15);
const TCHAR szOperation[]=_T("open");
const TCHAR szAddress[]=_T("https://www.cnblogs.com/zhdzh/");
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR lpCmd);
{
HINSTANCE hRslt=ShellExecute(0,szOperation,szAddress,0,0,SW_SHOWNORMAL);
assert(hRslt>(HINSTANCE)HINSTANCE_ERROR);
exit(100);
}
}
int main(){
Color(112);Cursorj(0);
Cursorg(15,4);printf("账号: ");
Cursorg(15,8);printf("密码: ");
Color(124);Cursorg(24,14);printf("确定!");
Color(127);
while(1){
Sleep(10);
if(!pt)while(_kbhit())_getch();
if(flag)break;
if(_kbhit()&&pt){
char ss=getche();
if(ss==13||ss==10){
if(pt==1){
if(len[1]){
pt++;
Cursorg(20+len[pt],8);
}
else Cursorg(20,4);
}
else{
if(len[2])test();
else Cursorg(20,8);
}
continue;
}
else if(ss==8){
--len[pt];
printf(" ");
Cursorg(20+len[pt],pt<<2);
continue;
}
a[pt][++len[pt]]=ss;
}
if(Key_Down(VK_LBUTTON)){
GetCursorPos(&p);
ScreenToClient(hw,&p);
GetCurrentConsoleFont(handle,0,&console);
int x=p.x/=console.dwFontSize.X;
int y=p.y/=console.dwFontSize.Y;
if((y==4||y==8)&&(x>=20&&x<=40)){
Cursorj(1);Color(12);
Cursorg(24,18);printf(" ");
if(y==4)pt=1;
else pt=2;
Cursorg(41,pt<<2);printf(" ");
Cursorg(20+len[pt],pt<<2);
Color(127);
}
else if(y==14&&(x>=24&&x<=29)){
Cursorj(0);
if(len[1]&&len[2]){
test();continue;
}
else {
if(!len[2]){
Cursorg(24,18);
Color(12);printf("请输入密码!");
Cursorg(41,8);printf("×");
}
if(!len[1]){
Cursorg(24,18);
Color(12);printf("请输入账号!");
Cursorg(41,4);printf("×");
}
}
}
else {
pt=0;
Cursorj(0);
}
}
}
exit(0);
}