全部评论 2

  • 安全版:

    #include <windows.h>
    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    using namespace std;
    
    int main() 
    {
    	// 设置随机数种子
    	srand(time(0));
    	
    	// 定义鼠标位置结构体
    	POINT mouse;
    	
    	// 当没有按下 ESC 键时,持续循环
    	while (!(GetAsyncKeyState(VK_ESCAPE) & 0x8000)) 
    	{
    		// 获取当前鼠标位置
    		GetCursorPos(&mouse);
    		
    		// 随机生成新的鼠标位置
    		mouse.x = rand() % GetSystemMetrics(SM_CXSCREEN); // 屏幕宽度范围
    		mouse.y = rand() % GetSystemMetrics(SM_CYSCREEN); // 屏幕高度范围
    		
    		// 输出新位置到控制台
    		cout << "Mouse Position: " << mouse.x << ", " << mouse.y << endl;
    		
    		// 设置鼠标到新位置
    		SetCursorPos(mouse.x, mouse.y);
    		
    		// 随机延迟一段时间(0-500毫秒)
    		Sleep(rand() % 500);
    	}
    	
    	cout << "程序已安全退出!" << endl;
    	return 0;
    }
    

    2026-11-02 来自 广东

    1
  • 谁敢运行

    2026-11-02 来自 广东

    0

热门讨论