InfoConnect API Guide
Attachmate.Reflection.Productivity Namespace / IScreenHistory Interface / GetHistoryScreenImage Method
The zero-based index of the history screen to capture. This must be a value between 0 and Count-1.
Example


In This Topic
    GetHistoryScreenImage Method
    In This Topic
    Returns a history screen as an image.
    Syntax
    'Declaration
     
    
    Function GetHistoryScreenImage( _
       ByVal index As Integer _
    ) As Byte()
    'Usage
     
    
    Dim instance As IScreenHistory
    Dim index As Integer
    Dim value() As Byte
     
    value = instance.GetHistoryScreenImage(index)
    byte[] GetHistoryScreenImage( 
       int index
    )

    Parameters

    index
    The zero-based index of the history screen to capture. This must be a value between 0 and Count-1.

    Return Value

    An image of the specified history screen.
    Exceptions
    ExceptionDescription
    This exception is thrown if the index does not correspond to a valid screen index in the current Screen History list.
    Remarks
    Returned images are subject to currently configured privacy filters. The returned image can be used in conjunction with the Productivity.OfficeTools CreateWordProcessingDocumentWithGraphicSet method if the installed Office Suite and Office Tools adapter assembly support the use of graphics in word-processing documents.
    Example
    This sample uses GetHistoryScreenImage to save the screens in the Screen History list as images in a Word document before the session is disconnected.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Attachmate.Reflection.UserInterface;
    using Attachmate.Reflection.Productivity;
    using Attachmate.Reflection.Emulation.IbmHosts;
    using Attachmate.Reflection.Framework;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using Word = Microsoft.Office.Interop.Word; 
    
    namespace ScreenHistory
    {
        class Program
        {
    
            static void terminal_BeforeDisconnect(object sender, EventArgs e)
            {
                IIbmTerminal terminal = (IIbmTerminal)sender;
    
                IScreenHistory history = terminal.Productivity.ScreenHistory;
    
                //Delete the first screen from the history
                history.DeleteScreen(0);
    
                List<Image> screenImages = new List<Image>();
    
    
    
                for (int i = 0; i < history.Count; i++)
                {
                    byte[] screenImage = history.GetHistoryScreenImage(i);
    
                    MemoryStream memstr = new MemoryStream(screenImage);
                    Image image = Image.FromStream(memstr);
    
    
    
                    screenImages.Add(image);
                }
    
    
                IOfficeTools tools = terminal.Productivity.OfficeTools;
    
                tools.CreateWordProcessingDocumentWithGraphicSet(screenImages, null, null);
    
    
                Word.Application word = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
    
    
                string screenLog = Environment.UserName + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                
                
                word.ActiveDocument.SaveAs(Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\" + screenLog);
                word.ActiveDocument.Close();
                word.Quit();
    
    
                history.SaveScreenHistoryFile(Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\myScreens.rshx", true);
            }
    
    
            static void Main(string[] args)
            {
                //Start a visible instance of InfoConnect or get the instance running at the given channel name
                Application app = MyReflection.CreateApplication("myWorkspace", true);
    
                //Create a terminal from the session document file
                string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\demoSession.rd3x";
                IIbmTerminal terminal = (IIbmTerminal)app.CreateControl(sessionPath);
    
                //Make the session visible in the workspace
                IFrame frame = (IFrame)app.GetObject("Frame");
                frame.CreateView(terminal);
    
                IScreenHistory history = terminal.Productivity.ScreenHistory;
    
                history.ManualCaptureOnly = false;
    
                history.ClearAllScreens();
    
                history.ScreenHistoryPanelVisible = true;
    
                history.NumberOfScreensToRemember = 25;
    
                history.ClearHistoryOnDisconnect = false;
    
                terminal.BeforeDisconnect += terminal_BeforeDisconnect;
    
                Console.ReadLine();
            }
    
    
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    See Also