InfoConnect for Unisys
Attachmate.Reflection.Productivity Namespace / IScreenHistory Interface / Count Property

In This Topic
    Count Property (IScreenHistory)
    In This Topic
    Returns the number of screens listed in the Screen History of the session.
    ReadOnly Property Count As Integer
    Dim instance As IScreenHistory
    Dim value As Integer
    value = instance.Count
    int Count {get;}
    This sample uses the Count property to check for an empty list.
    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 private List<Image> _screenImages = new List<Image>();
            static public List<Image>  ScreenImages
                get { return _screenImages; }
                set { _screenImages = value; }
            static void terminal_BeforeDisconnect(object sender, EventArgs e)
                IIbmTerminal terminal = (IIbmTerminal)sender;
                IScreenHistory history = terminal.Productivity.ScreenHistory;
                if (history.Count > 0)
                    IOfficeTools tools = terminal.Productivity.OfficeTools;
                    tools.CreateWordProcessingDocumentWithGraphicSet(ScreenImages, null, null);
                    string screenLog = Environment.UserName + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".docx";
                    Word.Application word = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
                    word.ActiveDocument.SaveAs(Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\" + screenLog);
                    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");
                IScreenHistory history = terminal.Productivity.ScreenHistory;
                history.ManualCaptureOnly = true;
                history.ScreenHistoryPanelVisible = true;
                history.NumberOfScreensToRemember = 25;
                history.ClearHistoryOnDisconnect = false;
                terminal.Screen.NewScreenReady += Screen_NewScreenReady;
                terminal.BeforeDisconnect += terminal_BeforeDisconnect;
            static void Screen_NewScreenReady(object sender, EventArgs e)
                IIbmScreen screen = (IIbmScreen) sender;
                Console.WriteLine(screen.GetText(1, 25, 30));
                if (screen.GetText(1, 25, 30).Contains("KAYAK"))
                    IScreenHistory history = screen.Parent.Productivity.ScreenHistory;
                    //Add to the ScreenImages list
                    byte[] screenImage = history.GetLiveScreenImage();
                    MemoryStream memstr = new MemoryStream(screenImage);
                    Image image = Image.FromStream(memstr);
    See Also