Reflection Desktop VBA Guide
Attachmate.Reflection.Objects Library / Attachmate.Reflection.Objects.Productivity Library / ScreenHistory Object / CaptureScreen Method
Example
In This Topic
    CaptureScreen Method
    In This Topic
    Captures the current host screen, including any data in non-hidden fields, and adds it to the Screen History list.
    Syntax
    expression.CaptureScreen() 
    where expression is a variable that represents a ScreenHistory Object
    Remarks
    If data in an unprotected field matches one or more currently enforced privacy filters, the first matching filter will replace the data in the screen capture image.

    For more about the CaptureScreen method, see:

    Using the Reflection Object Model

    Example

    This sample captures a specific screen in screen history when the screen opens. Other screens are not captured.

    To run this sample, create an Ibm3270 session with the host IP address set to demo:ibm3270.sim and then paste the code into the ThisIbmScreen code window. From the VBA editor View menu, choose Immediate Window. Then enter any credentials to log in and then enter kayak. On the Session ribbon, click Screen history to see the results.

    This example captures a screen and saves it in a screen history file.
    Private Sub IbmScreen_NewScreenReady(ByVal sender As Variant)
     
        Dim ScreenID As String
        Dim ScreenText As String
        
        ScreenID = "KAYAK"
        
        ScreenText = ThisIbmScreen.GetText(1, 39, 5)
        
        ThisIbmTerminal.Productivity.screenhistory.ManualCaptureOnly = True
        
        'If the screenID is on the screen, capture it
        
        If ScreenText = ScreenID Then
            Debug.Print "on the screen"
            
            ThisIbmTerminal.Productivity.screenhistory.CaptureScreen
            
        End If
     
    End Sub
    Sub CaptureAScreenAndSave()
        
        Dim shistory As ScreenHistory
        Dim rcode As ReturnCode
        Dim filename As String
        
        'Check or set the file name for the screen
        filename = InputBox("Save current screen image to:", , Environ("USERPROFILE") & "\Documents\Micro Focus\Reflection\Screen.rshx")
        
        'Get the history object and capture a screen
        Set shistory = ThisIbmTerminal.Productivity.ScreenHistory
        shistory.CaptureScreen
        
        'Save the screen to a screen history file
        rcode = shistory.SaveScreenHistoryFile(filename, True)
        
        'Clear the screen history and close the screen history panel
        shistory.ClearAllScreens
     
    End Sub
    See Also