看流星社区

 找回密码
 注册账号
查看: 1943|回复: 0

利用 SendInput 和INPUT结构模拟鼠标移动

[复制链接]

该用户从未签到

发表于 2020-4-2 14:30:05 | 显示全部楼层 |阅读模式

  1.     int x = GetDlgItemInt(IDC_EDIT1) ;   //要移动到的 x 坐标
  2.     int y = GetDlgItemInt(IDC_EDIT2) ;   //           y

  3.     int cx_screen = ::GetSystemMetrics(SM_CXSCREEN);  //屏幕 宽
  4.     int cy_screen = ::GetSystemMetrics(SM_CYSCREEN);  //     高

  5.     int real_x = 65535 * x / cx_screen;  //转换后的 x
  6.     int real_y = 65535 * y / cy_screen;  //         y

  7.     INPUT input;
  8.     input.type = INPUT_MOUSE;
  9.     input.mi.dx = real_x ;
  10.     input.mi.dy = real_y ;
  11.     input.mi.mouseData = 0;
  12.     //MOUSEEVENTF_ABSOLUTE 代表决对位置  MOUSEEVENTF_MOVE代表移动事件
  13.     input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;  
  14.     input.mi.time = 0;
  15.     input.mi.dwExtraInfo = 0;

  16.     SendInput(1,&input,sizeof(INPUT));
复制代码
点击按钮快速添加回复内容: 支持 高兴 激动 给力 加油 苦寻 生气 回帖 路过 感恩
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小黑屋|手机版|Archiver|看流星社区 |网站地图

GMT+8, 2024-4-25 17:33

Powered by Kanliuxing X3.4

© 2010-2019 kanliuxing.com

快速回复 返回顶部 返回列表