跳到正文

休闲·娱乐

整活·鼠标乱飞

struct_XC_约 2 分钟
原文
文章信息与版本

文章信息

发布
2024年7月25日
收录
2025年12月12日
更新
2026年11月21日
篇幅
约 2 分钟

版本

  1. v1当前

高风险代码!谨慎执行!

鼠标乱飞将持续12.48s

C++
#include<iostream>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
#include<ctime>
using namespace std;
void HideCursor(){
    CONSOLE_CURSOR_INFO cursor_info = {1, 0};
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
int main(){
	HideCursor();
	srand(time(0));
		HWND hwnd;
	hwnd = FindWindow("ConsoleWindowClass", NULL);
	if (hwnd) {
		ShowWindow(hwnd, SW_HIDE);
	}

	int x=GetSystemMetrics(SM_CXSCREEN);//get鼠标x轴
    int y=GetSystemMetrics(SM_CYSCREEN);//get鼠标y轴
    SetCursorPos(x/2,y/2);//鼠标 x y轴 随机
		for(int i=0;i<1000000;i++){
			SetCursorPos(rand()%x,rand()%y);
		}
	if (hwnd) {
		ShowWindow(hwnd, SW_HIDE);
	}

	return 0;
}
//Process exited after 12.48 seconds with return value 0
原文