#
# I tried with below code.
# I wanted to get contents of a unix vt100 window.
# I found text variable was initialised but empty.
# Guy below has a site [URL unfurl="true"]http://www.recook.com/WinRunner/TSL_Solutions.htm[/URL]
#
text="No text retrieved";
set_window("Untitled - Reflection for UNIX and Digital", 1);
if (obj_exists ("r2Display") == E_OK)
{
ObjGetTextWM("r2Display", text, 100);
print(text);
}
else
{
print("Aha!!!! Unix window not found");
}
################
# Retrieve text from an object by sending a Windows message. SOMETIMES works when obj_get_text() fails.
#
# Requirements
# Module win32api must be available, in the search path. It is installed by default in the WinRunner\lib folder.
# Object must be in GUI map.
# Set the window before calling function.
#
# Parameters
# object: logical name of the object
# output_text: variable that receives the captured text
# max_chars (optional): maximum number of characters to retrieve. Use only if you need more than the default value of 512.
#
# Return value
# rc >= 0: number of characters retrieved
# rc < 0: standard WinRunner return value
#
# Written by: Dr. Richard Cook
# Date: 2/22/2002
################
public function ObjGetTextWM(in object, out output_text, in max_chars)
{
auto WM_GETTEXT, api_module, rc, handle;
## Load the windows API module.
api_module = "win32api";
rc = load(api_module , 0, 1);
if(rc != E_OK)
return rc;
## Define the message constant (in Windows format).
WM_GETTEXT = 13;
## Define the default maximum number of characters to retrieve.
if( ! max_chars )
max_chars = 512;
## Get the object's handle in the variable handle.
rc = obj_get_info(object, "handle", handle);
if(rc != E_OK)
return rc;
## Send message requesting the text.
## Text is retrieved into the output_text variable.
rc = SendMessageString(handle, WM_GETTEXT , max_chars, output_text);
## Unload the module.
unload(api_module);
## Return code is the number of characters retrieved.
return rc;
} # end ObjGetTextWM()