Create an Event Procedure
You can add event procedures to any of the Reflection objects that support Automation events. Most of these objects appear in the Visual Basic Editor project pane (for example, IbmScreen or ThisScreen). For information about specific Reflection objects, see VBA Help from the Help menu.
To create an event procedure
- From Reflection 2011, open the Visual Basic Editor by clicking Tools > Visual Basic.
- In the Project Explorer window, expand the session project and then expand the Reflection Objects folder.
- Double-click the object for which you want to create an event procedure.
- In the upper-left corner of the Code window, from the Object list box, select the object name.
An event procedure is inserted into the Code window automatically.
- In the upper-right corner of the Code window, from the Procedures/Events list box, select the event procedure you want.
An empty event procedure is inserted in the Code window.
- In the procedure you just created, enter the code you want executed when the event occurs.
For example, the following code uses the BeforeSendControlKey event of the IbmScreen object to display a notification before sending a Control key:
Private Function IbmScreen_BeforeSendControlKey()
If MsgBox("Send Control key?", vbOKCancel) = vbYes Then
IbmScreen_BeforeSendControlKey = True
Note: This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Attachmate provides this sample code "AS IS" with no warranties.
- Choose File > Save [session filename] to save the Automation event as part of the session document.