2012-10-28 106 views
0

使用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); 
     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)对代替以一定的速度移动到它。

我希望能够控制这个速度。

+2

不知道有多少点但你需要一个定时器来多次调用SendInput()来设置光标的动画。不要期望用户弄乱它并故意移动鼠标。好吧,我会的。 –

回答

-1

所以最后我不得不使用一个本地方法我无法找到答案:

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

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

+1

仅供参考:您在使用非本地属性之前已使用本地函数。 – Bitterblue

+0

如果你可以提出更好的选择.. – Alex