MouseWheel Action

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use the MouseWheel action to simulate a rotation of the mouse wheel over the object, to which OnscreenObj corresponds.

Declaration

TestObj.MouseWheel(Delta, Shift)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Delta [in]    Required    Integer    
Shift [in]    Optional    TShiftKey Default value: skNoShift   
Result None

Applies To

All onscreen objects.

View Mode

To view this method in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Parameters

The method has the following parameters:

Delta

Specifies the number of detents the mouse wheel should be rotated. A detent is one wheel notch. A positive value means that the wheel will be rotated forward (away from the user); a negative value means the wheel will be rotated backward (toward the user).

Shift

Sets whether the Shift, Alt or Ctrl keys are pressed during the mouse wheel rotation (see TShiftKey). By default, this parameter is skNoShift (the shift keys are not pressed).

Result Value

None.

Example

The following example demonstrates how to use the MouseWheel action in scripts:

JavaScript, JScript

function MouseWheelExample()
{
 var npEdit = Sys.Process("notepad").Window("Notepad").Window("Edit");
 var text = "";
 for (var i = 0; i < 100; i++)
   text = text + "Line " + i + "\r\n";
 npEdit.wText = text;
 npEdit.Click();
 npEdit.MouseWheel(-10);
}

Python

def MouseWheelExample():
  npEdit = Sys.Process("notepad").Window("Notepad").Window("Edit")
  text = ""
  for i in range(0, 100):
    text = text + "Line " + aqConvert.IntToStr(i) + "\r\n"
  npEdit.wText = text
  npEdit.Click()
  npEdit.MouseWheel(-10)

VBScript

Sub MouseWheelExample
  Dim npEdit, text, i
  Set npEdit = Sys.Process("notepad").Window("Notepad").Window("Edit")
  text = ""
  For i = 0 To 100
    text = text & "Line " & i & vbNewLine
  Next
  npEdit.wText = text
  Call npEdit.Click()
  Call npEdit.MouseWheel(-10)
End Sub

DelphiScript

procedure MouseWheelExample;
var
  npEdit, text, i : OleVariant;
begin
  npEdit := Sys.Process('notepad').Window('Notepad').Window('Edit');
  text := '';
  for i := 0 to 100 do
  begin
    text := text + 'Line ' + aqConvert.IntToStr(i) + #13#10;
  end;
  npEdit.wText := text;
  npEdit.Click();
  npEdit.MouseWheel(-10);
end;

C++Script, C#Script

function MouseWheelExample()
{
 var npEdit = Sys["Process"]("notepad")["Window"]("Notepad")["Window"]("Edit");
 var text = "";
 for (var i = 0; i < 100; i++)
   text = text + "Line " + i + "\r\n";
 npEdit["wText"] = text;
 npEdit["Click"]();
 npEdit["MouseWheel"](-10);
}

See Also

Simulating User Actions
Simulating Mouse Wheel Rotation
MouseWheel Method

Highlight search results