LLPlayer.MouseMove Method

Applies to TestComplete 15.62, last modified on March 19, 2024

Description

Use the MouseMove method to simulate movement of the mouse cursor to the specified point on screen. This method performs the same action as the MouseMove event of a low-level procedure.

Declaration

LLPlayer.MouseMove(X, Y, Delay)

X [in]    Required    Integer    
Y [in]    Required    Integer    
Delay [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

X

The horizontal coordinate of the destination point. If X corresponds to a point that is out of the screen, the cursor will be stopped at the screen border.

Y

The vertical coordinate of the destination point. If Y corresponds to a point that is out of the screen, the cursor will be stopped at the screen border.

Delay

The number of milliseconds passed after you command TestComplete to simulate the movement of the cursor and before TestComplete starts simulating the movement. The delay gives you the possibility to better emulate real-life conditions. Also, the delay is necessary for the cursor movement to be properly processed by the operating system.

If Delay is negative, it is set to the Auto-wait timeout.

If Delay is greater than 1000, the waiting progress will be shown in the TestComplete indicator during the test run.

Result Value

None.

Example

The following script uses the LLPlayer object methods to simulate multiple selection with a Shift-click.

JavaScript, JScript

function LLPMouseMoveExample()
{
  // Specifies the coordinates of the first click
  var coordX = 15;
  var coordY = 120;

  // Specifies a delay in milliseconds
  var sDelay = 2000; // 2 seconds

  // Simulates pressing and releasing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, coordX, coordY, sDelay);
  LLPlayer.MouseUp(MK_LBUTTON, coordX, coordY, sDelay);

  // Simulates pressing the Shift key
  LLPlayer.KeyDown(VK_SHIFT, sDelay);

  // Specifies the coordinates of the destination point
  var destX = 98;
  var destY = 275;

  // Simulates mouse movement
  LLPlayer.MouseMove(destX, destY, sDelay);

  // Simulates pressing and releasing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, destX, destY, sDelay);
  LLPlayer.MouseUp(MK_LBUTTON, destX, destY, sDelay);

  // Simulates releasing the Shift key
  LLPlayer.KeyUp(VK_SHIFT, sDelay);
}

Python

def LLPMouseMoveExample():
  # Specifies the coordinates of the first click
  coorX = 15
  coorY = 120
  # Specifies a delay in milliseconds
  sDelay = 2000
  # 2 seconds
  # Simulates pressing and releasing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, coorX, coorY, sDelay)
  LLPlayer.MouseUp(MK_LBUTTON, coorX, coorY, sDelay)
  # Simulates pressing the Shift key
  LLPlayer.KeyDown(VK_SHIFT, sDelay)
  # Specifies the coordinates of the destination point
  destX = 98
  destY = 275
  # Simulates mouse movement
  LLPlayer.MouseMove(destX, destY, sDelay)
  # Simulates pressing and releasing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, destX, destY, sDelay)
  LLPlayer.MouseUp(MK_LBUTTON, destX, destY, sDelay)
  # Simulates releasing the Shift key
  LLPlayer.KeyUp(VK_SHIFT, sDelay)

VBScript

Sub LLPMouseMoveExample()

  ' Specifies the coordinates of the first click
  coordX = 15
  coordY = 120

  ' Specifies a delay in milliseconds
  sDelay = 2000 ' 2 seconds

  ' Simulates pressing and releasing the left mouse button
  Call LLPlayer.MouseDown(MK_LBUTTON, coordX, coordY, sDelay)
  Call LLPlayer.MouseUp(MK_LBUTTON, coordX, coordY, sDelay)

  ' Simulates pressing the Shift key
  Call LLPlayer.KeyDown(VK_SHIFT, sDelay)

  ' Specifies the coordinates of the destination point
  destX = 98
  destY = 275

  ' Simulates mouse movement
  Call LLPlayer.MouseMove(destX, destY, sDelay)

  ' Simulates pressing and releasing the left mouse button
  Call LLPlayer.MouseDown(MK_LBUTTON, destX, destY, sDelay)
  Call LLPlayer.MouseUp(MK_LBUTTON, destX, destY, sDelay)

  ' Simulates releasing the Shift key
  Call LLPlayer.KeyUp(VK_SHIFT, sDelay)

End Sub

DelphiScript

function LLPMouseMoveExample;
var coordX, coordY, sDelay, destX, destY;
begin

  // Specifies the coordinates of the first click
  coordX := 15;
  coordY := 120;

  // Specifies a delay in milliseconds
  sDelay := 2000; // 2 seconds

  // Simulates pressing and releasing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, coordX, coordY, sDelay);
  LLPlayer.MouseUp(MK_LBUTTON, coordX, coordY, sDelay);

  // Simulates pressing the Shift key
  LLPlayer.KeyDown(VK_SHIFT, sDelay);

  // Specifies the coordinates of the destination point
  destX := 98;
  destY := 275;

  // Simulates mouse movement
  LLPlayer.MouseMove(destX, destY, sDelay);

  // Simulates pressing and releasing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, destX, destY, sDelay);
  LLPlayer.MouseUp(MK_LBUTTON, destX, destY, sDelay);

  // Simulates releasing the Shift key
  LLPlayer.KeyUp(VK_SHIFT, sDelay);

end;

C++Script, C#Script

function LLPMouseMoveExample()
{
  // Specifies the coordinates of the first click
  var coordX = 15;
  var coordY = 120;

  // Specifies a delay in milliseconds
  var sDelay = 2000; // 2 seconds

  // Simulates pressing and releasing the left mouse button
  LLPlayer["MouseDown"](MK_LBUTTON, coordX, coordY, sDelay);
  LLPlayer["MouseUp"](MK_LBUTTON, coordX, coordY, sDelay);

  // Simulates pressing the Shift key
  LLPlayer["KeyDown"](VK_SHIFT, sDelay);

  // Specifies the coordinates of the destination point
  var destX = 98;
  var destY = 275;

  // Simulates mouse movement
  LLPlayer["MouseMove"](destX, destY, sDelay);

  // Simulates pressing and releasing the left mouse button
  LLPlayer["MouseDown"](MK_LBUTTON, destX, destY, sDelay);
  LLPlayer["MouseUp"](MK_LBUTTON, destX, destY, sDelay);

  // Simulates releasing the Shift key
  LLPlayer["KeyUp"](VK_SHIFT, sDelay);
}

See Also

Testing Applications in Low-Level Mode
MouseWheel Method
MouseDown Method
MouseUp Method
Low-Level Procedure Events
Simulating Mouse Wheel Rotation

Highlight search results