Getting a Button's Image in Desktop Windows Applications

Applies to TestComplete 15.69, last modified on November 13, 2024

Note: To learn how to simulate user actions over button controls in web applications, see Working With Button Controls in Web Applications.

While testing button 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.

The buttons you are working with may contain not only text, but also an image, which usually illustrates the button’s function. If you need to get this image, you can obtain it by using the wImage property. This property belongs to the Win32Button object, which is associated with standard Windows button controls during the test run. The wImage property returns the Picture object that contains the button’s image (for more information about the Picture object, see the Picture Object topic). The following code snippet obtains a button’s image and copies it to the clipboard:

JavaScript, JScript

...
bImage = Sys.Process("MyApp").Window("MainWin").Window("MyButton");
Sys.Clipboard = bImage.wImage;
...

Python

...
bImage = Sys.Process("MyApp").Window("MainWin").Window("MyButton")
Sys.Clipboard = bImage.wImage
...

VBScript

...
Set bImage = Sys.Process("MyApp").Window("MainWin").Window("MyButton")
Set Sys.Clipboard = bImage.wImage
...

DelphiScript

...
bImage := Sys.Process('MyApp').Window('MainWin').Window('MyButton');
Sys.Clipboard := bImage.wImage;
...

C++Script, C#Script

...
bImage = Sys["Process"]("MyApp")["Window"]("MainWin")["Window"]("MyButton");
Sys["Clipboard"] = bImage["wImage"];
...

See Also

Working With Button Controls in Desktop Windows Applications
wImage Property (Specific to Win32Button Controls)
Picture Object
Working With Button Controls in Web Applications

Highlight search results