跳到正文

个人记录

小病毒

_czx6666_约 2 分钟
原文

这是 2025年9月16日 存档的第 2 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年3月13日
篇幅
约 2 分钟

版本

  1. v4当前
  2. v3
  3. v2
  4. v1
C++
#include<bits/stdc++.h>
#include <Windows.h>
#include <TlHelp32.h>
POINT GetMousePosition() {
    POINT cursorPos;
    GetCursorPos(&cursorPos);
    return cursorPos;
}
void MouseClick(int x, int y) {
    SetCursorPos(x, y);
    mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, x,y);
    mouse_event(MOUSEEVENTF_LEFTUP, x, y, x, y);
}
void FixMousePosition() {
    srand(static_cast<unsigned>(time(nullptr)));
    const int screenWidth = GetSystemMetrics(SM_CXSCREEN) - 400;
    const int screenHeight = GetSystemMetrics(SM_CYSCREEN) - 300;
    while(true) {
    	const int posX = rand() % screenWidth;
    	const int posY = rand() % screenHeight;
    	char cmdCommand[256];
   		snprintf(cmdCommand, sizeof(cmdCommand),
        	"start cmd /k \"mode con: cols=80 lines=25 && title 随机位置CMD && color 9F\" "
        	"--window --pos %d,%d",
        posX, posY);
		system(cmdCommand);
        SetCursorPos(posX,posY); 
        MouseClick(posX,posY);
        Sleep(100); 
    }
}
void MouseControl() {
    FixMousePosition(); 
}
signed main(){
	
	MouseControl();
	

	return 0;
}