Reflection Desktop VBA Guide
Attachmate.Reflection.Objects.Emulation.OpenSystems Library / Attachmate.Reflection.Objects.Emulation.OpenSystems Library / Screen Object / KeysSending Event
Example
KeysSending Event
This event is triggered when a key is about to be sent to the host. KeysSending allows you to modify a key value or to cancel a send key action before it is sent.
Syntax
private Sub Screen_KeysSending ( 
   ByVal sender As Object, _
   ByRef keys As String _
) As Boolean

Parameters

sender
keys
Remarks

To cancel the action, set KeysSending to False.

Example
This example adds each key sent to the host to a buffer. When a controlkey is sent, it opens a file and appends the buffer and the controlkey code enum to the file. Then it closes the file and clears the buffer. To run this example, put the code at the top of the "ThisScreen" module. Then close and reopen your session and navigate to a few screens.
'Create a buffer to hold the keys entered
Dim buffer As String
 
'Add each key that is entered to the buffer
Private Function Screen_KeysSending(ByVal sender As Variant, Keys As String) As Boolean
    buffer = buffer & Keys   
    Screen_KeysSending = True
End Function
 
'Before the screen is changed, append the buffer to a text file.
Private Function Screen_ControlKeySending(ByVal sender As Variant, Key As Attachmate_Reflection_Objects_Emulation_OpenSystems.ControlKeyCode) As Boolean
    
    'Open a text file and append the data in the buffer to the file
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.OpenTextFile(ThisTerminal.SessionFilePath & ".log", 8, True)
    ts.Write buffer & "<Key(" & Key & ")>" & vbCrLf
    ts.Close
    
    'Clear the buffer
    buffer = ""
    
    Screen_ControlKeySending = True
    
End Function
See Also