Applies to TestComplete 12.20, last modified on January 17, 2017

Description

Use the MouseDown method to simulate pressing of a mouse button. The method performs the same action as the MouseDown event of a low-level procedure.

Declaration

LLPlayer.MouseDown(ButtonXYDelay)

Button [in]    Required    Integer    
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:

Button

A constant specifying the mouse button, the pressing of which is to be simulated. You can use the following constants to specify the mouse button:

Constant Integer Value Description
MK_LBUTTON 1 The left mouse button.
MK_RBUTTON 2 The right mouse button.
MK_MBUTTON 16 The middle mouse button.

X

Specifies the horizontal coordinate of the point for the click.

Y

Specifies the vertical coordinate of the point for the click.

Delay

The number of milliseconds passed after you command TestComplete to simulate the pressing of a mouse button and before TestComplete starts simulating the pressing. The delay gives you the possibility to better emulate real-life conditions. Also, it is necessary to separate the pressing from other low-level events in order to enable the operating system to properly process it.

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 code below simulates pressing the left mouse button and then releasing it using the MouseDown and MouseUp methods.

JavaScript, JScript

function LLPMouseButtonExample()
{
  // Specifies the coordinates of the click
  var coordX = 15;
  var coordY = 120;
  
  // Specifies a delay in milliseconds
  var sDelay = 2000; // 2 seconds
  
  // Simulates pressing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, coordX, coordY, sDelay);
  // ...
  // Simulates releasing the left mouse button
  LLPlayer.MouseUp(MK_LBUTTON, coordX, coordY, sDelay);
}

Python

def LLPMouseButtonExample():
  # Specifies the coordinates of the click
  coorX = 15
  coorY = 120
  # Specifies a delay in milliseconds
  sDelay = 2000 # 2 seconds
  # Simulates pressing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, coorX, coorY, sDelay)
  # Simulates releasing the left mouse button
  LLPlayer.MouseUp(MK_LBUTTON, coorX, coorY, sDelay)

VBScript

Sub LLPMouseButtonExample()

  ' Specifies the coordinates of the click
  coordX = 15
  coordY = 120
  
  ' Specifies a delay in milliseconds
  sDelay = 2000 ' 2 seconds
  
  ' Simulates pressing the left mouse button
  Call LLPlayer.MouseDown(MK_LBUTTON, coordX, coordY, sDelay)
  ' ...
  ' Simulates releasing the left mouse button
  Call LLPlayer.MouseUp(MK_LBUTTON, coordX, coordY, sDelay)
    
End Sub

DelphiScript

function LLPMouseButtonExample;
var coordX, coordY, sDelay;
begin

  // Specifies the coordinates of the click
  coordX := 15;
  coordY := 120;
  
  // Specifies a delay in milliseconds
  sDelay := 2000; // 2 seconds
  
  // Simulates pressing the left mouse button
  LLPlayer.MouseDown(MK_LBUTTON, coordX, coordY, sDelay);
  // ...
  // Simulates releasing the left mouse button
  LLPlayer.MouseUp(MK_LBUTTON, coordX, coordY, sDelay);

end;

C++Script, C#Script

function LLPMouseButtonExample()
{
  // Specifies the coordinates of the click
  var coordX = 15;
  var coordY = 120;
  
  // Specifies a delay in milliseconds
  var sDelay = 2000; // 2 seconds
  
  // Simulates pressing the left mouse button
  LLPlayer["MouseDown"](MK_LBUTTON, coordX, coordY, sDelay);
  // ...
  // Simulates releasing the left mouse button
  LLPlayer["MouseUp"](MK_LBUTTON, coordX, coordY, sDelay);
}

See Also

Testing Applications in Low-Level Mode
MouseUp Method
MouseMove Method
MouseWheel Method
Low-Level Procedure Events
MouseDown Method (Desktop Objects)
Simulating Mouse Wheel Rotation