Hello Simon,
sure, as you can see it is very easy to understand the scan process. It is a recursive call with the sub procedure GetIDs. In this sub procedure I add to outText variable the ID, Name and Text (Value) of the control.I start the scan in the main sub procedure with a collection of a session.
'-Begin-----------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
On Error Resume Next
'-Variables-----------------------------------------------------------
Dim outText
'-Sub GetIDs----------------------------------------------------------
Sub GetIDs(collection)
'-Variables-------------------------------------------------------
Dim i, Child
'outText = outText & collection.Id() & vbCrLf
'outText = outText & collection.Name() & vbCrLf
outText = outText & collection.Text() & vbCrLf
Set Child = collection.Children()
If IsObject(Child) Then
If Child.Count() > 0 Then
For i = 0 To Child.Count() - 1
GetIDs Child.Item(CInt(i))
Next
End If
End If
End Sub
'-Sub Main------------------------------------------------------------
Sub Main()
'-Variables-------------------------------------------------------
Dim SapGuiAuto, application, connection, session, i
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
Exit Sub
End If
Set application = SapGuiAuto.GetScriptingEngine
If Not IsObject(application) Then
Exit Sub
End If
Set connection = application.Children(0)
If Not IsObject(connection) Then
Exit Sub
End If
Set session = connection.Children(0)
If Not IsObject(session) Then
Exit Sub
End If
For i = 0 To session.Children().Count() - 1
GetIDs session.Children(CInt(i))
Next
End Sub
'-Main----------------------------------------------------------------
Main()
MsgBox outText
'-End-------------------------------------------------------------------
Hope it is no problem to transfer it in C# syntax.
Enjoy it.
Cheers
Stefan