锁定鼠标&乱搞鼠标

自己做了个会锁定鼠标或让鼠标乱飞的程序

打开exe会让鼠标指针“不听使唤”

话不多说,直接上代码:

【锁定鼠标】

#define _CRT_SECURE_NO_WARNINGS //strcat()所需
#include<iostream>              //输入输出
#include<string>                //字符串处理
#include<Windows.h>             //Windows系统
#include<thread>                //线程
#include<tchar.h>               //_T()等
using namespace std;            //为了方便

#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)

int main(){
	int x = GetSystemMetrics(SM_CXSCREEN);//获取屏幕分辨率x和y,
	int y = GetSystemMetrics(SM_CYSCREEN);//将鼠标锁定在屏幕中间
	system("color a0");
	cout<<"system screen:"<<x<<"×"<<y<<".\n";
	cout<<"system mouse will be locked at:"<<x/2<<"-"<<y/2<<"\n";
	//cout<<"mouse pos:"<<GetCursorPos(NULL)<<"\n";
	cout<<"if you want to quit, press F3.";
	Sleep(1000);
	system("cls");
	system("color 09");
	int vol=1;
	while(vol==1){
		cout<<"哈哈哈,你的鼠标动不了了!!!\n";
		cout<<"距离锁定结束还有:\n";
		int i=200000;
		while (i){
			if(KEY_DOWN(VK_F3)){
				break;//按F3可以退出
			}
		    SetCursorPos(x/2, y/2);
		    //Sleep(2);
		    cout<<"\b\b\b\b\b\b\b"<<i;
		    i--;
		}
		system("cls");
		vol=MessageBox(NULL,"继续锁定鼠标吗?","tip",MB_OKCANCEL|MB_ICONQUESTION);
		if(vol==2)return i;
	}
}

下载:>点这里<

【乱搞鼠标】

#define _CRT_SECURE_NO_WARNINGS //strcat()所需
#include<iostream>              //输入输出
#include<string>                //字符串处理
#include<Windows.h>             //Windows系统
#include<thread>                //线程
#include<tchar.h>               //_T()等
using namespace std;            //为了方便

#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)

int main(){
	int x = GetSystemMetrics(SM_CXSCREEN);
	int y = GetSystemMetrics(SM_CYSCREEN);
	int vol=1;
	system("color a0");
	cout<<"system screen:"<<x<<"×"<<y<<".\n";
	cout<<"your mouse will be random set/0.02sec\n";
	//cout<<"mouse pos:"<<GetCursorPos(NULL)<<"\n";
	cout<<"if you want to quit, press F3.";
	Sleep(1000);
	system("cls");
	system("color 09");
	while(vol==1){
		cout<<"哈哈哈,你的鼠标正在乱飞!!!\n";
		cout<<"距离乱飞结束还有:\n";
		int i=1000;
		while (i){
			if(KEY_DOWN(VK_F3)){
				break;//按F3可以退出
			}
		    SetCursorPos(rand() % x, rand() % y);
		    Sleep(1);
		    cout<<"\b\b\b\b\b"<<i;
		    i--;
		}
		system("cls");
		vol=MessageBox(NULL,"继续乱搞鼠标吗?","tip",MB_OKCANCEL|MB_ICONQUESTION);
		if(vol==2)return i;
	}
}

下载:>点这里<

温馨提示:如果过程中要退出,请按 [ F3 ] 或 [ Alt ] + [ F4 ]。

  • 9
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值