WaitForCursor

Waits for the cursor to reach the specified screen position. This also works for VT emulation, but since VT is character based, WaitForCursorColumn is usually more useful there.


Syntax

FlexScreen.WaitForCursor(Position, [WaitMSec])


Parameters


Position

Integer, input



Integer value of the zero-based screen position the cursor should reach, which may be obtained by using the FlexScreen.Position method.


[WaitMSec]

Integer, input, optional



Number of milliseconds before the wait times out.


Remarks

If the optional WaitMSec parameter is specified, it is the maximum wait time. If it is omitted, FlexScreen.WaitTimeoutMSec is used (20000 unless changed).


WaitForCursor returns True as soon as the cursor is at the position, or False if the wait times out. If FlexScreen.EnableRuntimeError is True (the default), a timeout raises run-time error &H80131505, "Function 'WaitForCursor' timed out after n ms.", and unless the macro handles the error, it stops. If the session is not connected, run-time error &H80131320, "The session is not connected.", is raised instead.


Note that under On Error Resume Next, the assignment is skipped when the error is raised. So a variable such as Ok keeps its previous value instead of becoming False. To test the result, set FlexScreen.EnableRuntimeError to False and check the return value (see EnableRuntimeError).


Example

Sub Main()

  Ok = FlexScreen.WaitForCursor(FlexScreen.Position(10, 11))

  Ok = FlexScreen.SendKeys("MyUserID")

  Ok = FlexScreen.SendKeys(FlexKey.ENTER)

End Sub