C# 控制输入鼠标移动速度
使用Sendinput方法时是否可以控制鼠标指针的速度 例如,这是我的代码:C# 控制输入鼠标移动速度,c#,winforms,mouse,sendinput,C#,Winforms,Mouse,Sendinput,使用Sendinput方法时是否可以控制鼠标指针的速度 例如,这是我的代码: public static void ClickMouseDOWN(int x, int y) { INPUT mouseInput = new INPUT(); mouseInput.type = (int)InputType.INPUT_MOUSE; mouseInput.mi.dx = CalculateAbsoluteCoordinateX(x);
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+Mouse Button Press down命令,但问题是指针移动到int x,int y的位置,而不是以恒定的速度移动到它
我希望能够控制这种速度。我找不到答案,所以最后我不得不使用本机方法:
Cursor.Position = new Point(x, y);
我可以在将光标移动到新位置时指定Thread.SleepZ不确定它有多大意义,但您需要一个计时器多次调用SendInput来设置光标动画。不要期望用户故意弄乱它并移动鼠标。嗯,我会的。仅供参考:您以前使用过本机函数,现在使用的是非本机属性。