输入模拟器平滑线性小鼠在2分之间移动



我正在努力弄清为什么下面的功能只将鼠标从0、0屏幕坐标移至我的最终目的地,即使Cursor.position.position.position返回正确的屏幕坐标。如果有人能启发我,我将最感激。

public void MoveAndClick(int x, int y, int steps)
{
    Point start = Cursor.Position;
    PointF iterPoint = start;
    PointF slope = new PointF(x - start.X, y - start.Y);
    slope.X = slope.X / steps;
    slope.Y = slope.Y / steps;
    for(int i=0; i<steps; i++)
    {
        iterPoint = new PointF(iterPoint.X + slope.X, iterPoint.Y + slope.Y);
        inputSim.Mouse.MoveMouseTo(iterPoint.X, iterPoint.Y);
        Thread.Sleep(10);
    }
    inputSim.Mouse.MoveMouseTo(x, y);
    inputSim.Mouse.RightButtonDown();
    inputSim.Mouse.RightButtonUp();
}

取自https://stackoverflow.com/a/913703/2014393

doh!昏昏欲睡并上床睡觉时始终停止工作。

InputSimulator库要求您像这样翻译坐标:

int startX = 65535 * Cursor.Position.X / Screen.PrimaryScreen.Bounds.Width;
int startY = 65535 * Cursor.Position.Y / Screen.PrimaryScreen.Bounds.Height;

我正在转换端坐标,但完全忘记了转换启动坐标,derp。

flaui允许鼠标平稳移动。这是FLAUI中的鼠标类。

最新更新