Applies to TestComplete 14.30, last modified on November 21, 2019

Description

TShiftKey is an enumerated type that indicates whether the Shift, Ctrl or Alt key is pressed while executing a Click, DblClick or Drag action over a control. TShiftKey defines the following constants for shift keys:

Constant Description
skShift The Shift key is pressed.
skAlt The Alt key is pressed.
skCtrl The Ctrl key is pressed.
skNoShift Neither Ctrl, Shift nor Alt pressed.

Remarks

TShiftKey values are additive. To specify that several keys are pressed at once, combine the needed constants using the bitwise logical OR operator:

JavaScript, JScript

MyObject.Click (10, 10, skCtrl | skShift);

Python

MyObject.Click(10, 10, skCtrl | skShift)

VBScript

Call MyObject.Click (10, 10, skCtrl Or skShift)

DelphiScript

MyObject.Click (10, 10, skCtrl or skShift);

C++Script, C#Script

MyObject["Click"](10, 10, skCtrl | skShift);

Example

The following example illustrates how you can select the desired text by using the skShift constant and post it to the test log:

JavaScript, JScript

function TextSelection()
{
  var p = Sys.Process("notepad");
  var w = p.Window("Notepad", "Untitled - Notepad", 0);
  w = w.Window("Edit", "", 0);
  w.Keys("That's very important");
  w.Click(100,10);
  w.Click (190, 10, skShift);
  var sText = w.wSelection;
  Log.Message(sText);
}

Python

def TextSelection():
  p = Sys.Process("notepad")
  w = p.Window("Notepad", "Untitled - Notepad", 0)
  w = w.Window("Edit", "", 0)
  w.Keys("That's very important")
  w.Click(100,10)
  w.Click (190, 10, skShift)
  sText = w.wSelection
  Log.Message(sText)

VBScript

Sub TextSelection
  Set p = Sys.Process("notepad")
  Set w = p.Window("Notepad", "Untitled - Notepad", 0)
  Set w = w.Window("Edit", "", 0)
  w.Keys "That's very important"
  Call w.Click (100, 10)
  Call w.Click (190, 10, skShift)
  sText = w.wSelection
  Log.Message(sText)
End Sub

DelphiScript

procedure TextSelection;
var
  p, sText, w : OleVariant;
begin
  p := Sys.Process('notepad');
  w := p.Window('Notepad', 'Untitled - Notepad', 0);
  w := w.Window('Edit', '', 0);
  w.Keys('That''s very important');
  w.Click(100, 10);
  w.Click (190, 10, skShift);
  sText := w.wSelection;
  Log.Message(sText);
end;

C++Script, C#Script

function TextSelection()
{
  var p = Sys["Process"]("notepad");
  var w = p["Window"]("Notepad", "Untitled - Notepad", 0);
  w = w["Window"]("Edit", "", 0);
  w["Keys"]("That's very important");
  w["Click"](100,10);
  w["Click"] (190, 10, skShift);
  var sText = w["wSelection"];
  Log["Message"](sText);
}

See Also

Simulating Mouse Wheel Rotation
Simulating Selection of Items and Nodes
Click Action
ClickM Action
ClickR Action
DblClick Action
DblClickM Action
DblClickR Action
Drag Action
DragM Action
DragR Action

Highlight search results