Reflection Desktop VBA Guide
Attachmate.Reflection.Objects.Emulation.IbmHosts Library / Attachmate.Reflection.Objects.Emulation.IbmHosts Library / IbmScreen Object / BeforeSendControlKey Event
Example
BeforeSendControlKey Event
Occurs before a control key is sent to the host.
Syntax
private Sub IbmScreen_BeforeSendControlKey ( 
   ByVal sender As Object, _
   ByRef key As Integer _
) As Boolean

Parameters

sender
The source of the event.
key
Control Key.

Return Value

A boolean value that determines whether the event is cancelled.

If set to false (the default), the event is cancelled and the key is not sent to the host.

If set to true, the key is sent to the host.

Remarks
The value of parameter key is the control key that is about to be sent. In the event handler function you may change the control key value before it is sent to the host. The event can also be canceled by setting the return value of the event handler function to false. The return value false is the default if your event handler does not explicitly set it. If you cancel the event, the control key will not be sent to the host. By setting the function return value to true, the event continues with the control key value in the parameter key, which could be a different control key value set by the event handler.

For more about using the BeforeSendControlKey event, see:

Save Screens as Text

Save Screens to Word as Images

Example
This sample captures the screen before the control key is sent and appends it to a text file.
Private Function IbmScreen_BeforeSendControlKey(ByVal sender As Variant, key As Long) As Boolean
    Dim screenRows As Integer
    Dim screenColumns As Integer
    Dim fnum As Integer
    Dim screenShot As String
    screenRows = ThisIbmScreen.rows
    screenColumns = ThisIbmScreen.columns
    
 
   
    'Get all the text on the screen
    screenShot = ThisIbmScreen.GetTextEx(1, 1, screenRows, screenColumns, GetTextArea_Block, _
    GetTextWrap_Off, GetTextAttr_Any, GetTextFlags_CRLF)
   
    'Add a line to separate each screen
    screenShot = screenShot & "................................................................................"
   
    'Open a file and append the screenshot to the file
    path = ThisIbmTerminal.SessionFilePath & ".log"
    fnum = FreeFile()
    Open path For Append As fnum
    Print #fnum, screenShot
    Close #fnum
    
    Debug.Print path
   
    IbmScreen_BeforeSendControlKey = True
End Function
See Also