1 Star 0 Fork 1

saigon/Algorithms

forked from charlieshu/Algorithms 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
鼠标控制模板.cpp 2.36 KB
一键复制 编辑 原始数据 按行查看 历史
charlie 提交于 2024-01-09 00:01 . move from github to gitee
#include <iostream>
#include <Windows.h>
using namespace std;
void Mouse_Move(int x, int y) {
double fScreenWidth = ::GetSystemMetrics(SM_CXSCREEN) - 1;
double fScreenHeight = ::GetSystemMetrics(SM_CYSCREEN) - 1;
double fx = x * (65535.0f / fScreenWidth);
double fy = y * (65535.0f / fScreenHeight);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, fx, fy, 0, 0);
return;
}
void Mouse_left_click() {
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
Sleep(10);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
return;
}
void Mouse_right_click() {
mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
Sleep(10);
mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
return;
}
void Mouse_left_down() {
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
return;
}
void Mouse_left_up() {
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
return;
}
void Mouse_right_down() {
mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
return;
}
void Mouse_right_up() {
mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
return;
}
void Mouse_middle_down() {
mouse_event(MOUSEEVENTF_MIDDLEDOWN,0,0,0,0);
return;
}
void Mouse_middle_up() {
mouse_event(MOUSEEVENTF_MIDDLEUP,0,0,0,0);
return;
}
int main() {
int x,y;
cout<<"please input moving-number:\n";
cin>>x;
POINT p;
while(p.x < x) {
::GetCursorPos(&p);
Mouse_Move(p.x+1, (p.x-250)*(p.x-250)*0.002);
Sleep(100);
}
return 0;
}
//#include<iostream>
//#include<conio.h>
//#include<windows.h>
//
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) //必要的,我是背下来的
//
//using namespace std;
//
//int main(){
// char a;
// int now=0;
// printf("按Q开始左键点击\n");
// printf("按W开始右键点击\n");
// printf("按空格停止点击\n");
// while(1){
// if(KEY_DOWN(VK_SPACE)){//VK_SPACE 是空格的虚拟键值
// now=0;
// Sleep(100);//你的手不会再一瞬间送开,所以要处理一下
// }
// if(KEY_DOWN('Q')){
// now=1;
// Sleep(100);
// }
// if(KEY_DOWN('W')){
// now=2;
// Sleep(100);
// }
// if(now==1){//模拟点击左键
// mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
// Sleep(10);//要留给某些应用的反应时间
// mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
// }
// if(now==2){//模拟点击右键
// mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
// Sleep(10);
// mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
// }
//
// Sleep(20);//点击间隔 单位是毫秒
// }
//}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/saigonshu/algorithm.git
git@gitee.com:saigonshu/algorithm.git
saigonshu
algorithm
Algorithms
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385