我正在努力弄清楚为什么下面的函数只会将我的鼠标从 0、0 屏幕坐标移动到我的最终目的地,即使 Cursor.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();
}