首页 文章

控制发送输入鼠标移动速度

提问于
浏览
1

使用Sendinput方法时是否可以控制鼠标指针的速度?

例如,这是我的代码:

public static void ClickMouseDOWN(int x, int y)
    {
        INPUT mouseInput = new INPUT();
        mouseInput.type = (int)InputType.INPUT_MOUSE;
        mouseInput.mi.dx = CalculateAbsoluteCoordinateX(x);
        mouseInput.mi.dy = CalculateAbsoluteCoordinateY(y);
        mouseInput.mi.mouseData = 0;

// mouse teleports instantly
            mouseInput.mi.dwFlags = (int)MOUSEEVENTF.MOVE | (int)MOUSEEVENTF.ABSOLUTE;
            SendInput(1, new INPUT[] { mouseInput }, Marshal.SizeOf(mouseInput));
// mouse teleports instantly

        mouseInput.mi.dwFlags = (int)MOUSEEVENTF.LEFTDOWN;
        SendInput(1, new INPUT[] { mouseInput }, Marshal.SizeOf(mouseInput));

    }

下面的代码执行MouseMovement鼠标按钮按(向下)命令,但问题是指针传送到位置(int x,int y)而不是以某个恒定速度移动到它 .

我希望能够控制这种速度 .

1 回答

  • -1

    我找不到答案,所以最后我不得不使用原生方法:

    Cursor.Position = new Point(x, y);
    

    我可以在将光标移动到新位置时指定 Thread.Sleep(Z)

相关问题