How to get the text from any standard object
2010-03-10 16:05
686 查看
The code below shows how you can get the text from any standard object without using text recognition.
Standard Examples
'Get text from a ListView - report style (for example, Windows Explorer)
msgbox Window("C:\Program Files\Mercury").WinListView("SysListView32").GetSubItem(1,2)
'Get text from a toolbar
msgbox Window("C:\Program Files\Mercury").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
' An example for a Web Table (in the Mercury Tour site)
Set Cell = Browser("Welcome: Mercury Tours").Page("Select a Flight: Mercury").WebTable("RETURN").ChildItem(3, 2, "WebElement", 0)
Msgbox Cell.GetROProperty("innertext")
Visual Basic Example
'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
'Get the text of items in a CheckListBox (has no Test Object)
'Get run-time object reference
Set CustList = SwfWindow("Win").SwfObject(ìlst").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
' 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
Standard Examples
'Get text from a ListView - report style (for example, Windows Explorer)
msgbox Window("C:\Program Files\Mercury").WinListView("SysListView32").GetSubItem(1,2)
'Get text from a toolbar
msgbox Window("C:\Program Files\Mercury").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
' An example for a Web Table (in the Mercury Tour site)
Set Cell = Browser("Welcome: Mercury Tours").Page("Select a Flight: Mercury").WebTable("RETURN").ChildItem(3, 2, "WebElement", 0)
Msgbox Cell.GetROProperty("innertext")
Visual Basic Example
'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
'Get the text of items in a CheckListBox (has no Test Object)
'Get run-time object reference
Set CustList = SwfWindow("Win").SwfObject(ìlst").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
' 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
相关文章推荐
- From an inner class, "this" points to the inner object. How do I get a "this" pointer to the enclosing object?
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- How to Get the Best Image Quality from Your IP Camera
- How to get the DOM of a WebBrowser control from a window handle (VB6)
- How to find a node by its text using the GetNodeByText method
- How to get IBA values from a soft typed object
- How to get the Values of Selected Row from a Gridview using ASP.NET
- How can i specify the resource to get from R.res.drawable dynamically?
- HOWTO get multiple value from the same name checkbox elements or radiobution elements
- [SharePoint]javascript client object model 获取lookup 类型的field的值,包括user类型(单人或者多人)的值。how to get the multiple user type/lookup type field value by Javascript client object model
- string - How to get the filename without the extension from a path in Python? - Stack Overflow
- [eZ publish] When a ezxml embed an video, how to get the ezxml object in the video embed template?
- How to get the data from a cell when I click on the GridButtonColumn of the same row
- how to get the return value from a thread in python?
- how to get the default maximum heap size for Sun's JVM from Java SE 6 or 7
- How to get the object type in javascript:
- How to get the Projection ProjectionMatrixFromCameraIntrinsics
- How to get the object type in javascript:
- How to get the nearest parent node given a text node in jQuery?
- USBView & How to get the Serial Number from a USB disk & qextserialport