controlling sendinput mouse movement speed
Domanda
Is it possible to control the speed of the mouse pointer when using Sendinput method?
For example this is my code:
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));
}
Following code executes MouseMovement + Mouse Button Press (down) command, but the problem is that the pointer teleports at the position (int x, int y) instead of moving to it at some constant speed.
I want to be able to control that speed.
Soluzione
I couldn't find an answer so in the end I had to use a native method:
Cursor.Position = new Point(x, y);
i can specify Thread.Sleep(Z)
when moving the cursor to new position
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow