看流星社区

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

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

[复制链接]

该用户从未签到

发表于 2013-3-21 08:34:42 | 显示全部楼层 |阅读模式
int x = GetDlgItemInt(IDC_EDIT1) ;   //要移动到的 x 坐标
    int y = GetDlgItemInt(IDC_EDIT2) ;   //           y

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

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

    INPUT input;
    input.type = INPUT_MOUSE;
    input.mi.dx = real_x ;
    input.mi.dy = real_y ;
    input.mi.mouseData = 0;
    input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;   //MOUSEEVENTF_ABSOLUTE 代表决对位置  MOUSEEVENTF_MOVE代表移动事件
   input.mi.time = 0;
    input.mi.dwExtraInfo = 0;

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

本版积分规则

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

GMT+8, 2024-5-6 00:38

Powered by Kanliuxing X3.4

© 2010-2019 kanliuxing.com

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