InfoConnect API Guide
Programming Concepts / Navigating Sessions
Navigating Sessions

You can use InfoConnect methods to navigate through your sessions:

Navigating Through IBM Screens

Navigating Through Open Systems Programs

Finding and Moving to Screen Locations

Navigating Through IBM Screens

Using the NewScreenReady event along with the GetText function, you can identify specific screens when they are ready. You can then use the PutText and SendControlKey methods to enter commands that navigate to the next screen.

Navigate through screens using the NewScreenReady event
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 Navigate
{
    class Program
    {
        static void screen_NewScreenReady(object sender, EventArgs e)
        {
            IIbmScreen screen = (IIbmScreen)sender;

            //Get strings that are unique to each screen you want to navigate
            string screenID1 = screen.GetText(1, 2, 3);
            string screenID2 = screen.GetText(1, 1, 5);

            //Compare each screen ID with a known value to determine
            //which screen the program is on. Then use the SendKeys and
            //SendControlKey methods to navigate to the next screen
            if (screenID1 == "ATM")
            {
                screen.SendControlKey(ControlKeyCode.Transmit);
            }
            if (screenID2 == "LOGON")
            {
                screen.SendKeys("kayak");
                screen.SendControlKey(ControlKeyCode.Transmit);
            }
        }

        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 and configure a terminal for an Ibm 3270 session and connect
            IIbmTerminal terminal = (IIbmTerminal)app.CreateControl(new Guid("{09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1}"));       
            terminal.HostAddress = "demo:ibm3270.sim";
            terminal.Port = 623;
            terminal.Connect();

            //Make the session visible               
            IFrame frame = (IFrame)app.GetObject("Frame");
            frame.CreateView(terminal);
    
            //Create an event handler for the NewScreenReady event
            IIbmScreen screen = terminal.Screen;
            screen.NewScreenReady += screen_NewScreenReady;

            Console.ReadKey();
        }
    }
}

Navigating Through Open Systems Programs

After sending data to a host, using VT or other non-block mode emulation, you must pause execution until you determine when the host has finished with its reply.

Navigate a session
Copy Code
//For any terminal screen, you can use the following methods to navigate 
 IScreen screen = terminal.Screen;
       
//Wait for the host before entering commands
screen.Wait(3000);
screen.SendKeys("demodata");
screen.SendControlKey(ControlKeyCode.Enter);

//Wait for the host before entering additional commands
screen.Wait(3000);
//additional commands...
        

 

Finding and Moving to Screen Locations

You can use InfoConnect Search functions to find locations on the screen that you want to use as a starting point for a selection.

By adding the following code to the sample for Navigating Through IBM Screens, you can modify the sample to find and select text.

Find a screen location and move the cursor
Copy Code
//Add this code to the NewScreenReady event in the Navigating Through IBM Screens sample

//Add another screen ID
string screenID3 = screen.GetText(1, 25, 13);

............................
//Add this code to find and select text when the screen is recognized
if (screenID3 == "INTERNATIONAL")
{
    //Find a screen location
    ScreenPoint point = screen.SearchText("East", 1, 1, FindOption.Forward);

     //Move the cursor and select some text
     if (point != null)
     {
         screen.MoveCursorTo(point.Row, point.Column);
         screen.SetSelectionStartPos(point.Row, point.Column);
         screen.ExtendSelection(point.Row, screen.Columns);
      }
 }