我用
Mouse_Event(MOUSEEVENTF_MOVE,50,0,0,0);
来模拟鼠标移动,为什么只能向右移动50,却不能设置-50,请问如何向左移动?

解决方案 »

  1.   

    可以用SetCursorPos(X,Y)
    这个函数是指定鼠标的位置,其坐标是相对整个屏幕
      

  2.   

    不行啊 我在游戏中模拟不能用 setcursorpos啊下面摘侄MSDN
    If the user moved the mouse, which is indicated by a value of dwFlags that includes MOUSEEVENTF_MOVE, dx and dy hold information about that motion. The information is specified as absolute or relative integer values. If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, and (65535,65535) maps onto the lower-right corner. If the MOUSEEVENTF_ABSOLUTE value is not specified, dx and dy specify relative motions from the position reported when the last mouse event was generated. Positive values mean that the user moved the mouse right or down; negative values mean that the user moved the mouse left or up. Relative mouse motion is subject to the settings for mouse speed and acceleration level. An end user sets these values using the Mouse control panel application. An application obtains and sets these values by using the SystemParametersInfo function. 不知道这句什么意思?
    Positive values mean that the user moved the mouse right or down; negative values mean that the user moved the mouse left or up. 
      

  3.   

    给你一段代码参考一下:让鼠标移动到控件上的方法
    procedure MoveMouseIntoControl(AWinControl: TWincontrol);
    var
      rtControl: TRect;
    begin
      rtControl := AWinControl.BoundsRect;
      MapWindowPoints(AWinControl.Parent.Handle, 0, rtControl, 2);
      SetCursorPos(rtControl.Left + (rtControl.Right - rtControl.Left) div 2,
      rtControl.Top + (rtControl.Bottom - rtControl.Top) div 2);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      MoveMouseIntoControl(Button1);
    end;
      

  4.   

    我在游戏里只能用
    Mouse_Event(MOUSEEVENTF_MOVE,50,0,0,0);
    来模拟鼠标啊,其他的都不行,试过了
    但是只能向右和下移动,怎么样才能向左和上移动?
      

  5.   

    终于搞定了
    Mouse_Event(MOUSEEVENTF_MOVE,$ffff-50,0,0,0);  这样就是向左移动了  哈哈
      

  6.   

    TO kiss2() 
    真為你感到高興!