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

    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));
本人新博客网址为:http://www.hizds.com
本博客注有“转”字样的为转载文章,其余为本人原创文章,转载请务必注明出处或保存此段。c++/lua/windows逆向交流群:69148232
原文地址:https://www.cnblogs.com/zhangdongsheng/p/2697810.html