Determining the Number of Trackbar Ticks in Desktop Windows Applications

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

While testing trackbar controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

In your tests, you may need to obtain the number of trackbar ticks. To work with trackbars, you can use specific properties and methods, provided by the Win32TrackBar object. During the test run, TestComplete associates this object with standard trackbar controls whose class names are listed in the Object Mapping list of the project’s options.

To determine the number of ticks, you can use the wNumTics property. This property returns the total number of ticks of the tested trackbar, including the first and last tick marks. The following sample code posts the total number of tick marks to the test log:

JavaScript, JScript

function Main()
{
var p, w, TrackBar;

  // Obtain the trackbar object
p = Sys.Process("Explorer").Window("Shell_TrayWnd").Window("TrayNotifyWnd").Window("SysPager").Window("ToolbarWindow32", "Notification Area");
  p.ClickItemR("Volume", false);
  p.PopupMenu.Click("Open Volume Control");
  w = Sys.Process("SNDVOL32").Window("Volume Control", "Master Volume");
  TrackBar = w.Window("msctls_trackbar32", "", 4);

  // Post the total number of ticks to the log
  Log.Message(TrackBar.wNumTics);
}

Python

def Main():

  # Obtain the trackbar object
  p = Sys.Process("Explorer").Window("Shell_TrayWnd").Window("TrayNotifyWnd").Window("SysPager").Window("ToolbarWindow32", "Notification Area")
  p.ClickItemR("Volume", False)
  p.PopupMenu.Click("Open Volume Control")
  w = Sys.Process("SNDVOL32").Window("Volume Control", "Master Volume")
  TrackBar = w.Window("msctls_trackbar32", "", 4)

  # Post the total number of ticks to the log
  Log.Message(TrackBar.wNumTics)

VBScript

Sub Main
Dim p, w, TrackBar

  ' Obtain the trackbar object
  Set p = Sys.Process("Explorer").Window("Shell_TrayWnd").Window("TrayNotifyWnd").Window("SysPager").Window("ToolbarWindow32", "Notification Area")
  Call p.ClickItemR("Volume", False)
  Call p.PopupMenu.Click("Open Volume Control")
  Set w = Sys.Process("SNDVOL32").Window("Volume Control", "Master Volume")
  Set TrackBar = w.Window("msctls_trackbar32", "", 4)

  ' Post the total number of ticks to the log
  Log.Message(TrackBar.wNumTics)
End Sub

DelphiScript

procedure Main();
var 
  p, w, TrackBar: OleVariant;
begin
  // Obtain the trackbar object
  p := Sys.Process('Explorer').Window('Shell_TrayWnd').Window('TrayNotifyWnd').Window('SysPager').Window('ToolbarWindow32', 'Notification Area');
  p.ClickItemR('Volume', false);
  p.PopupMenu.Click('Open Volume Control');
  w := Sys.Process('SNDVOL32').Window('Volume Control', 'Master Volume');
  TrackBar := w.Window('msctls_trackbar32', '', 4);

  // Post the total number of ticks to the log
  Log.Message(TrackBar.wNumTics);
end;

C++Script, C#Script

function Main()
{
var p, w, TrackBar;

// Obtain trackbar object
p = Sys["Process"]("Explorer")["Window"]("Shell_TrayWnd")["Window"]("TrayNotifyWnd")["Window"]("SysPager")["Window"]("ToolbarWindow32", "Notification Area");
p["ClickItemR"]("Volume", false);
p["PopupMenu"]["Click"]("Open Volume Control");
w = Sys["Process"]("SNDVOL32")["Window"]("Volume Control", "Master Volume");
TrackBar = w["Window"]("msctls_trackbar32", "", 4);

// Post the total number of ticks to the log
Log["Message"](TrackBar.wNumTics);
}

See Also

Working With Trackbar Controls in Desktop Windows Applications
wNumTics Property (TrackBar Controls)

Highlight search results