#include<bits/stdc++.h>
#include<windows.h>
#define key(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) 
using namespace std;
int shake[4][4]={{3,0},{0,-3},{-3,0},{0,3}};
void qmWindows(HWND hwnd,int a,int b,int c,int d){
	RECT rect;
	GetWindowRect(hwnd,&rect); 
	MoveWindow(hwnd,rect.left+a,rect.top+b,rect.right-rect.left+c,rect.bottom-rect.top+d,TRUE);
}
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); 
}
void ksbj(){
	HANDLE a =GetStdHandle(STD_INPUT_HANDLE);
	DWORD b;
	GetConsoleMode(a,&b);
	b &= ~ENABLE_QUICK_EDIT_MODE;
	SetConsoleMode(a,b);	
}
void movep( int  x ,  int  y ){	
	COORD  point = {  x ,  y  }; 
	HANDLE  HOutput = GetStdHandle( STD_OUTPUT_HANDLE ); 
	SetConsoleCursorPosition(HOutput, point); 
}
POINT popxy(){
	POINT p;
	CONSOLE_FONT_INFO k;
	GetCursorPos(&p);
	ScreenToClient(GetForegroundWindow(),&p);
	GetCurrentConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE),FALSE,&k);
	p.x=p.x/k.dwFontSize.X;
	p.y=p.y/k.dwFontSize.Y;
	return p;
}
int fh(int a){
	return a/abs(a);
}
int main(){
	srand(time(NULL));
	int h=200,w=200;
	ksbj();
	gbc(0);
	HWND hwnd=GetForegroundWindow();
	//SetWindowLong(hwnd, GWL_STYLE,GetWindowLong(hwnd, GWL_STYLE) & ~(WS_CAPTION | WS_SIZEBOX));
	long long zq=0;
	while(1){
		movep(0,0);
		bool onw=0;
		if(popxy().x+popxy().y>=0&&popxy().x<=20&&popxy().y<=10)
			onw=1;
		
		SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 100, 100, SWP_NOMOVE | SWP_NOSIZE);
		
		RECT rect;
		GetWindowRect(hwnd,&rect); 
		
		int cx = GetSystemMetrics(SM_CXFULLSCREEN);
		int cy = GetSystemMetrics(SM_CYFULLSCREEN);
		
		//cout<<cx<<"  "<<rect.left;
		/*t=30;
		while(t>0){
		t--;
		if(key(VK_LBUTTON)&&onw==1)
		break;
		qmWindows(hwnd , 0 , -g*t*0.4 , 0 , 0);
		Sleep(10);
		}*/
		
		int g=4.7,t=0;
		int p=30;
		
		if(key(VK_LBUTTON)&&onw==1){
			POINT p,p1;
			GetCursorPos(&p1);
			Sleep(5);
			int zq1=zq%4;
			//cout<<zq1<<endl;
			qmWindows(hwnd,shake[zq1][0],shake[zq1][1],0,0);
			zq++;
			GetCursorPos(&p);
			qmWindows(hwnd,p.x-p1.x,p.y-p1.y,0,0);
			continue;
		}
		
		MoveWindow(hwnd,rect.left,rect.top,h,w,TRUE);
		
		
		if(key(VK_SPACE)){
			t=30;
			while(t>0){
				t--;
				if(key(VK_LBUTTON)&&onw==1)
					break;
				qmWindows(hwnd , 0 , -g*t*0.4 , 0 , 0);
				Sleep(10);
			}
		}
		
		if(rand()%1600==0){
			
			if(rand()%3!=3){
				int d=pow(-1,rand()%100);
				int d1=rand()%(int)(cx*0.4)+100;
				int tarx=rect.left+d1*d;
				while(1){
					if(key(VK_LBUTTON)&&onw==1)
						break;
					GetWindowRect(hwnd,&rect);
					if(abs(tarx-rect.left)<=10){
						MoveWindow(hwnd,tarx,rect.top,rect.right-rect.left,rect.bottom-rect.top,TRUE);
						break;
					}
					qmWindows(hwnd,(tarx-rect.left)*0.1,0,0,0);
					if(rect.left<=0){
						MoveWindow(hwnd,0,rect.top,rect.right-rect.left,rect.bottom-rect.top,TRUE);
						d=1;
						d1=rand()%(int)(cx*0.2)+100;
						tarx=rect.left+d1*d;
						while(1){
							if(key(VK_LBUTTON)&&onw==1)
								break;
							GetWindowRect(hwnd,&rect);
							if(abs(tarx-rect.left)<=10){
								MoveWindow(hwnd,tarx,rect.top,rect.right-rect.left,rect.bottom-rect.top,TRUE);
								break;
							}
							qmWindows(hwnd,(tarx-rect.left)*0.1,0,0,0);
							Sleep(10);
						}
						break;
					}
					if(rect.right>=cx){
						MoveWindow(hwnd,cx-rect.right+rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,TRUE);
						d=-1;
						d1=rand()%(int)(cx*0.2)+100;
						tarx=rect.left+d1*d;
						while(1){
							if(key(VK_LBUTTON)&&onw==1)
								break;
							GetWindowRect(hwnd,&rect);
							if(abs(tarx-rect.left)<=10){
								MoveWindow(hwnd,tarx,rect.top,rect.right-rect.left,rect.bottom-rect.top,TRUE);
								break;
							}
							qmWindows(hwnd,(tarx-rect.left)*0.1,0,0,0);
							Sleep(10);
						}
						break;
					}
					Sleep(10);
				}
			}
			
			else{
				t=rand()%35+5;
				while(t>0){
					t--;
					if(key(VK_LBUTTON)&&onw==1)
						break;
					qmWindows(hwnd , 0 , -g*t*0.4 , 0 , 0);
					Sleep(10);
				}
				
			}
			
		}
		
		if(rect.top<cy-rect.bottom+rect.top+p){
			while(rect.top < cy-rect.bottom+rect.top+p){
				if(key(VK_LBUTTON)&&onw==1)
					break;
				GetWindowRect(hwnd,&rect);
				t++;
				if(rect.top+g*t > cy-rect.bottom+rect.top+p){
					MoveWindow(hwnd,rect.left,cy-rect.bottom+rect.top+p,rect.right-rect.left,rect.bottom-rect.top,TRUE);
					if(t<=1)t=0;
				}
				else{
					qmWindows(hwnd , 0 , g*t , 0 , 0);
				}
				Sleep(10);
			}
			while(t>0){
				t--;
				if(key(VK_LBUTTON)&&onw==1)
					break;
				qmWindows(hwnd , 0 , -g*t*0.4 , 0 , 0);
				
				//cout<<t<<endl;
				Sleep(10);
			}
		}
	}
}

删掉if(rand()%1600==0){}中的东西就不会乱跑