Events

When working under the Application object, you can access RumbaApplicationObject events.

Add the following code to the Application object to show a message box each time an active session opens:

Private Sub RumbaApplicationObject_OnOpenSession(ByVal sessionID As Long)
    MsgBox "Opened"
End Sub

Add the following code to the Application object to show a message box each time an active session changes:

Private Sub RumbaApplicationObject_OnActiveSessionChange(ByVal previousActiveSessionID As Long, ByVal currentActiveSessionID As Long)
MsgBox "Active session changed." 
End Sub

The events defined under the Application object are persistent. This means that the events are triggered for any instance of Rumba (even without the VBA editor being open), and also when launched from an external application such as Microsoft Excel. See Working with External Applications.

More events are available using the RumbaEmulationSessionObject object. Defining the object using the WithEvents keyword provides another set of events.

Dim WithEvents Emul As RumbaEmulationSessionObject

The Procedure list shows the available events:

GUID-DB087637-55C0-4109-A84C-21F0516615F6-low.png

The following example shows how to use the OnCursorPositionChange event to display a message box each time the cursor changes position:

Private Sub Emul_OnCursorPositionChange(ByVal Row As Long, ByVal Column As Long)
    MsgBox "The new cursor position is: " & Row & ", " & Column
End Sub

The following example shows how to use the OnConnectionStateChange event to display a message box each time a successful connection is established:

Private Sub Emul_OnConnectionStateChange(ByVal oldState As RumbaAutomation.RumbaConnectionState, ByVal newState As RumbaAutomation.RumbaConnectionState)
    If (newState = RumbaConnectionState_Connected) Then
        MsgBox "Connection established."
    End If
End Sub