text.cpp

来自「打开」· C++ 代码 · 共 44 行

CPP
44 行
字号
#include <iostream.h>
#include <windows.h>

void getMousePos()
{
   POINT point;
   GetCursorPos(&point);
   cout<<point.x<<"  "<<point.y<<endl;
}
 
void moveMouse()
{
	cout<<"请输入鼠标新坐标:"<<endl;
	int a,b;
	cout<<"x方向:";
	cin>>a;
	cout<<"y方向:";
	cin>>b;
    SetCursorPos(a,b);	
}

void main()
{
	cout<<"鼠标位置演示"<<endl;
         cout<<"1 获取鼠标当前位置"<<endl
	<<"2 移动鼠标"<<endl
	<<"其他键退出"<<endl;
	while(1)
	{
		int choice;
		cout<<endl<<"请输入操作:";
		cin>>choice;
		switch(choice)
		{
		    case 1:  getMousePos();break;
		    case 2:  moveMouse();break;
		    default: exit(1);break;
		}
	}
}



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?