Getting Status Bar Panes' Images in Desktop Windows Applications

Applies to TestComplete 15.46, last modified on January 09, 2023

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.

Status bar panes can contain not only information about the application, but also images that illustrate this information. If you need to obtain an image associated with a certain pane, you can use specific properties and methods belonging to the Win32StatusBar object. TestComplete associates this object with status bar controls whose class names are specified in the Object Mapping project's options.

You can obtain the image that corresponds to the status bar pane specified by its index or caption via the wImage property. This property returns the Picture object corresponding to the image of the specified pane or an empty object, if the specified pane does not have an image associated with it. You can process the obtained image the same way you process ordinary images. For more information on available actions, see the Picture object description.

The following sample code demonstrates how to obtain panes’ images and post them to the test log:

JavaScript

function Main()
{
  var p, w, StatusBar, PaneNumber;

  // 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);
  
  // Log information about the panes' images
  PaneNumber = StatusBar.wPartCount;
  for (let i = 0; i< PaneNumber; i++)
    if (!strictEqual(StatusBar.wImage(i), null))
      Log.Picture(StatusBar.wImage(i), "Pane's image");
    else
      Log.Message("Pane does not have an image.");
}

JScript

function Main()
{
  var p, w, i, StatusBar, PaneNumber;

  // 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);
  
  // Log information about the panes' images
  PaneNumber = StatusBar.wPartCount;
  for (i = 0; i< PaneNumber; i++)
    if (StatusBar.wImage(i) != null)
      Log.Picture(StatusBar.wImage(i), "Pane's image");
    else
      Log.Message("Pane does not have an image.");
}

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)
  
  # Log information about the panes' images
  PaneNumber = StatusBar.wPartCount 
  for i in range(0, PaneNumber-1):
    if (StatusBar.wImage[i] != None):
      Log.Picture(StatusBar.wImage[i], "Pane's image")
    else:
      Log.Message("Pane does not have an image.")

VBScript

Sub Main
  Dim p, w, i, StatusBar, PaneNumber

  ' 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)
  
  ' Log information about the panes' images
  PaneNumber = StatusBar.wPartCount
  For i = 0 To PaneNumber-1
    If Not (StatusBar.wImage(i) Is Nothing) Then
      Call Log.Picture(StatusBar.wImage(i), "Pane's image")
    Else
      Log.Message("Pane does not have an image.")
    End If
  Next 
End Sub 

DelphiScript

procedure Main();
var 
  p, w, i, StatusBar, PaneNumber: 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);
  
  // Log information about the panes' images
  PaneNumber := StatusBar.wPartCount;
  for i := 0 to PaneNumber-1 do
    if (StatusBar.wImage(i) <> nil)
    then
      Log.Picture(StatusBar.wImage(i), 'Pane''s image')
    else
      Log.Message('Pane does not have an image.');
end;

C++Script, C#Script

function Main()
{
  var p, w, i, StatusBar, PaneNumber;

  // 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);
  
  // Log information about the panes' images
  PaneNumber = StatusBar["wPartCount"];
  for (i = 0; i< PaneNumber; i++)
    if (StatusBar["wImage"](i) != null)
      Log["Picture"](StatusBar["wImage"](i), "Pane's image");
    else
      Log["Message"]("Pane does not have an image.");
}

See Also

Working With Status Bar Controls in Desktop Windows Applications
wImage Property (StatusBar Controls)
Picture Object

Highlight search results