Clicking within a Status Bar Pane in Desktop Windows Applications

Applies to TestComplete 15.42, last modified on September 08, 2022

A status bar can contain various information about the application, so it is usually divided into several panes, each representing a certain type of information. You may need to perform a click within a specified pane.

While testing status bar 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.

To work with standard status bar controls TestComplete uses the Win32StatusBar object. During the test run, TestComplete associates this object with status bar controls whose class names are listed in the project’s Object Mapping options.

Win32StatusBar provides a number of actions that you can use to simulate a click on the status bar control:

  • The Click, DblClick, ClickR and similar actions that correspond to the tested status bar control. You can estimate the coordinates of the needed status bar pane and simulate a click via these actions. The specified coordinates are relative to the object.
  • The ClickItem, ClickItemR and similar actions that correspond to status bar panes and allow you to simulate a click on the status bar's pane specified by its index or caption.
  • The ClickItemXY, ClickItemRXY and similar actions that correspond to status bar panes and allow you to simulate a click on the specified point within a pane. The specified coordinates should be relative to the top left corner of the pane’s rectangular region. See Determining the Bounds of a Status Bar Pane in Desktop Windows Applications to get detailed information on how to determine the dimensions of the specified status bar pane.

The following sample code demonstrates how to use Click actions in scripts. It determines the bounds of the second pane, estimates the coordinates of the point to click and clicks on the specified point. After that, it clicks in the center of the first status bar pane.

JavaScript, JScript

function Main()
{
  var p, w, StatusBar, Size, x, y;

  // Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL);
  
  // Obtain the status bar control
  p = Sys.Process("Explorer");
  w = p.Window("ExploreWClass", "My Documents", 1);
  StatusBar = w.Window("msctls_statusbar32", "", 1);
  
  // Obtain the item's bounds and specify the point to click
  Size = StatusBar.wItemBounds(1);
  x = Size.Width - 10;
  y = Size.Height - 10;

  // Click on the specified point
  StatusBar.ClickItemXY(1, x, y);
  
  // Click in the center of the first pane
  StatusBar.ClickItem(0);
}

Python

def Main():

  # Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL)
  
  # Obtain the status bar control
  p = Sys.Process("Explorer")
  w = p.Window("ExploreWClass", "My Documents", 1)
  StatusBar = w.Window("msctls_statusbar32", "", 1)
  
  # Obtain the item's bounds and specify the point to click 
  Size = StatusBar.wItemBounds[1]
  x = Size.Width - 10
  y = Size.Height - 10

  # Click on the specified point
  StatusBar.ClickItemXY(1, x, y)
  
  # Click in the center of the first pane 
  StatusBar.ClickItem(0)

VBScript

Sub Main
  Dim p, w, StatusBar, Size, x, y

  ' Open My Documents
  Call WshShell.Run("explorer.exe", SW_NORMAL)
  
  ' Obtain the status bar control
  Set p = Sys.Process("Explorer")
  Set w = p.Window("ExploreWClass", "My Documents", 1)
  Set StatusBar = w.Window("msctls_statusbar32", "", 1)
  
  ' Obtain the item's bounds and specify the point to click
  Set Size = StatusBar.wItemBounds(1)
  x = Size.Width - 10
  y = Size.Height - 10

  ' Click on the specified point
  StatusBar.ClickItemXY 1, x, y
  
  ' Click in the center of the first pane
  StatusBar.ClickItem 0
End Sub

DelphiScript

procedure Main();
var 
  p, w, StatusBar, Size, x, y: OleVariant;
begin
  // Open My Documents
  WshShell.Run('explorer.exe', SW_NORMAL);
  
  // Obtain the status bar control
  p := Sys.Process('Explorer');
  w := p.Window('ExploreWClass', 'My Documents', 1);
  StatusBar := w.Window('msctls_statusbar32', '', 1);
  
  // Obtain the item's bounds and specify the point to click
  Size := StatusBar.wItemBounds(1);
  x := Size.Width - 10;
  y := Size.Height - 10;

  // Click on the specified point
  StatusBar.ClickItemXY(1, x, y);
  
  // Click in the center of the first pane
  StatusBar.ClickItem(0);
end;

C++Script, C#Script

function Main()
{
  var p, w, StatusBar, Size, x, y;

  // Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL);
  
  // Obtain the status bar control
  p = Sys["Process"]("Explorer");
  w = p["Window"]("ExploreWClass", "My Documents", 1);
  StatusBar = w["Window"]("msctls_statusbar32", "", 1);
  
  // Obtain the item's bounds and specify the point to click
  Size = StatusBar["wItemBounds"](1);
  x = Size["Width"] - 10;
  y = Size["Height"] - 10;

  // Click on the specified point
  StatusBar["ClickItemXY"](1, x, y);
  
  // Click in the center of the first pane
  StatusBar["ClickItem"](0);
}

See Also

Working With Status Bar Controls in Desktop Windows Applications
Determining the Bounds of a Status Bar Pane in Desktop Windows Applications
Click Action
ClickItem Action (StatusBar Controls)
ClickItemXY Action (StatusBar Controls)

Highlight search results