Get Started > Create an Invisible Session |
You can create or open a session that runs without displaying the workspace and session.
This sample opens a session document and makes the workspace invisible. Data is copied from the screen and displayed in the console.
Open the InfoConnect workspace and create a demo session as follows:
If you are using IBM, create an IBM3270 session with a host name of "demo:ibm3270.sim" and save the session as demoSession.rd3x in the default folder (...\myDocuments\Micro Focus\InfoConnect.)
If you are using Open Systems, create a VT session with a host name of "demo:UNIX" and save the session as demoSession.rdox in the default folder.
Create an invisible session |
Copy Code
|
---|---|
using System; using System.Collections.Generic; using System.Text; using Attachmate.Reflection.Framework; using Attachmate.Reflection.Emulation.IbmHosts; using Attachmate.Reflection.UserInterface; namespace CreateSessionFromExistingSessionFile { class Program { static void Main(string[] args) { //Start an invisible instance of InfoConnect or get the instance running at the given channel name Application app = MyReflection.CreateApplication("myWorkspace", false); //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); //Create a view for the session IFrame frame = (IFrame)app.GetObject("Frame"); frame.CreateView(terminal); //Get a handle to the screen. Then wait until it is ready and get the maximum columns and rows IIbmScreen screen = terminal.Screen; screen.WaitForHostSettle(3000, 2000); int maxCols = screen.Columns; int maxRows = screen.Rows; //Get the text on the screen and write it to the Console. string text = screen.GetTextEx(1, 1, maxRows, maxCols, GetTextArea.Block, GetTextWrap.On, GetTextAttr.Any, GetTextFlags.None); Console.WriteLine(text); //Close InfoConnect app.Close(ApplicationCloseOption.CloseNoSave); Console.ReadLine(); } } } |
Example Title |
Copy Code
|
---|---|
using System; using System.Collections.Generic; using System.Text; using Attachmate.Reflection.Framework; using Attachmate.Reflection.Emulation.OpenSystems; using Attachmate.Reflection.UserInterface; namespace CreateSessionFromExistingSessionFile { class Program { static void Main(string[] args) { //Start an invisible instance of InfoConnect or get the instance running at the given channel name Application app = MyReflection.CreateApplication("myWorkspace", false); //Create a terminal from the session document file string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\demoSession.rdox"; ITerminal terminal = (ITerminal)app.CreateControl(sessionPath); //Create a view for the session IFrame frame = (IFrame)app.GetObject("Frame"); frame.CreateView(terminal); //Get a handle to the screen and wait until it is ready IScreen screen = terminal.Screen; screen.WaitForHostSettle(6000, 3000); //Get the text in the display memory and write it to the Console int maxrows = screen.DisplayRows; int maxcols = screen.DisplayColumns; string text = screen.GetText(1, 1, maxrows, maxcols); Console.WriteLine(text); //Close InfoConnect app.Close(ApplicationCloseOption.CloseNoSave); Console.ReadLine(); } } } |
Press F5 to run the project and verify that the text from the session is displayed in the Console.