Getting Standard Text

The code below shows how you can get the text from any standard object without using text recognition.

These examples are written in VBScript. To write similar code in Python, replace programming language statements with Python ones. For Object Model steps, you can use the same syntax but make sure all method calls enclose the arguments in parentheses '()' . Use empty parentheses '()' when calling a method with no arguments.

Standard Examples

Copy code
'Get text from a ListView - report style (for example, Windows Explorer)
msgbox Window("C:\Program Files\OpenText").WinListView("SysListView32").GetSubItem(1,2)

'Get text from a toolbar
msgbox Window("C:\Program Files\OpenText").WinToolbar("ToolbarWindow32").GetItem(1)

'Text of a message-box, the Static control is not in the object repository/shared object ' 'repository
set StatObj = Dialog("DlgTB").Dialog("DlgTB").Static("nativeclass:=Static","Index:=1")
msgbox StatObj.GetROProperty("text")

Web Example

Copy code
' An example for a Web Button (in the Advantage Online Shopping site)
Set item = Browser("Advantage Shopping").Page("Advantage Shopping").WebButton("sign_in_btnundefined")
msgbox item.GetROProperty("innertext")

Visual Basic Example

Copy code
'Retrieving the text of a label in a VB form: (There is no Test Object for a label)
msgbox VbWindow("VBForm1").Object.Controls("Label1").caption

.NET Example

Copy code
'Get the text of items in a CheckListBox (has no Test Object)

'Get run-time object reference
Set CustList = SwfWindow("Win").SwfObject("List").Object
'Get Items collection
Set ListItems = CustList.get_Items()
'Get Items count
ItemsCount = ListItems.Count
'Loop over all items
For i = 0 to ItemsCount-1
    text = text & ListItems.Item(i)
Next

ActiveX Example

Copy code
' This example will retrieve the text from the Visual Basic Flight 1A sample application's flight grid
' This retrieves the flight number from the 3rd row.
VbWindow("VbWindow").VbWindow("VbWindow").AcxTable("Grid Control").Object.Row = 3
VbWindow("VbWindow").VbWindow("VbWindow").AcxTable("Grid Control").Object.Col = 0
msgbox VbWindow("VbWindow").VbWindow("VbWindow").AcxTable("Grid Control").Object.Text