Hi Daniel,
unfortunately there is no out of the box method to achieve this.
Here is a Function that you can use to search a portion of the screen, either a rectangular portion or a portion that wraps around at the end of line.
Private Function myWaitForStringInArea(myString As String, ByRef startRow As Integer, ByRef startCol As Integer, ByRef endRow As Integer, ByRef endCol As Integer, ByRef BlockOrStream As Boolean, ByRef Timeout As Long) As Boolean
Dim TextInSearchRegion As String, StringFound As Integer, SetTimeout As Long
StartTime = Timer
StringFound = 0
SetTimeout = Timeout
Do While Timer - StartTime < (SetTimeout / 1000)
TextInSearchRegion = ThisIbmScreen.GetTextEx(startRow, startCol, endRow, endCol, BlockOrStream, GetTextWrap_Off, GetTextAttr_Any, GetTextFlags_None)
StringFound = InStr(1, UCase(TextInSearchRegion), UCase(myString))
If StringFound > 0 Then
If BlockOrStream = 0 Then
absolutePosition = startRow * ThisIbmScreen.columns + startCol + StringFound
startRow = CInt(absolutePosition / ThisIbmScreen.columns)
startCol = (absolutePosition Mod 80) - 1
Else
relativePosition = startRow * (endCol - startCol + 1)
startRow = startRow + CInt((StringFound) / (endCol - startCol + 1))
startCol = startCol + CInt((StringFound) Mod (endCol - startCol + 1)) - 1
End If
Timeout = (Timer - StartTime) * 1000
myWaitForStringInArea = True
Exit Do
Else
myWaitForStringInArea = False
End If
Loop
If myWaitForStringInArea = False Then
startRow = 0
startCol = 0
Timeout = 0
End If
End Function
To use this function you provide the text you are looking for, the area in which you want to wait for the text, whether it's a block (rectangular) or not (then it's stream) and a timeout in milliseconds.
The function returns True if the text is found in the search area. If the text is found, the position of the string you are waiting for is returned in the startRow and startCol parameter variables and the duration of the wait is returned in the timeout parameter.
If the text is not found, then the function returns False, and the startRow, endRow and Timeout parameter are all returned as 0.
Here is a sample call from inside a routine. If sets the search area to row 5 from column 2 to 3 and checks that for for a "d" anywhere in that area
:
:
:
Dim myString As String
Dim startRow As Integer
Dim startCol As Integer
Dim endRow As Integer
Dim endCol As Integer
Dim Block As Boolean 'True == Rectangular area, False == Stream with wrapping at end of line
Dim Timeout As Long
Dim Found As Boolean
' ThisIbmScreen.SendControlKey ControlKeyCode_Transmit
startRow = 10
startCol = 2
endRow = 10
endCol = 3
myString = "d"
Block = True
Timeout = 10000
Found = myWaitForStringInArea(myString, startRow, startCol, endRow, endCol, Block, Timeout)
If Found = True Then
MsgBox "Found Text string " & Chr$(34) & myString & Chr$(34) & " at Row: " & startRow& " Col: " & startCol & " in " & Timeout & "msec"
Else
MsgBox "Text did not appear before the wait timed out"
End If
:
:
If you need something similar in the legacy Reflection COM api, then you can follow the same logic to create your own custom WaitForMyCondition,