Hotspots are virtual buttons that appear over text in terminal sessions. By using hotspots, you can control your terminal session with the mouse instead of the keyboard. Typically, clicking a hotspot transmits a terminal key or command to the host, but you can also configure hotspots to open a Web page, launch a macro, or perform a variety of other actions.
Hotspots are defined in configuration files that are distributed with Reflection. You can create a new custom hotspot file on the fly. You can also load hotspot files when certain screens load or specific commands are entered.
Add a Hotspot
Load a Hotspots File for a Specific Screen or Command
Add a Hotspot
This sample creates a new hotspot by copying and modifying the default hotspot file.
To add a hotspot
-
Open the Reflection 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\Reflection.)
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.
- In Visual Studio, create a new Console Application project and add references for the following Reflection assemblies. (Depending on your version of Visual Studio, these can be found either on the .NET tab or under Assemblies | Extensions.)
Attachmate.Reflection
Attachmate.Reflection.Framework
Attachmate.Reflection.Emulation.IbmHosts (if you're using IBM)
Attachmate.Reflection.Emulation.OpenSystems (if you're using UNIX or OpenVMS)
- Replace all the code in the Program.cs file with the following code for the terminal you are using.
Add a hotspot |
Copy Code
|
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Attachmate.Reflection.Framework;
using Attachmate.Reflection.Emulation.IbmHosts;
using Attachmate.Reflection.UserInterface;
using Attachmate.Reflection;
namespace Hotspots
{
class Program
{
static void Main(string[] args)
{
//Start a visible instance of Reflection or get the instance running at the given channel name
Attachmate.Reflection.Framework.Application reflectionApplication = MyReflection.CreateApplication("myWorkspace", true);
//Create a terminal for an Ibm 3270 session and a view to make the session visible
string sessionFilePath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\";
IIbmTerminal terminal = (IIbmTerminal)reflectionApplication.CreateControl(sessionFilePath + "demoSession.rd3x");
IFrame frame = (IFrame)reflectionApplication.GetObject("Frame");
frame.CreateView(terminal);
//Get a handle to the screen hotspots object
IIbmScreen screen = terminal.Screen;
IHotSpots myHotspots = screen.HotSpots;
//Load the custom hotspots file if it exists. If not, create it.
if (File.Exists(sessionFilePath + @"Hotspots Maps\myHotspots.xhs") == true)
{
myHotspots.ConfigureHotSpots(sessionFilePath + @"Hotspots Maps\myHotspots.xhs");
}
else
{
//Set up an action sequence to create an email when the hotspot is clicked
InputMapAction actionToCreateEmail = new InputMapAction(InputMapActionID.EmailMessageAction, null);
InputMapActionSequence sequence = new InputMapActionSequence();
sequence.Add(actionToCreateEmail);
Hotspot KayakHotSpot = new Hotspot("KAYAK", sequence);
//Add the hotspots to the default session hotspots map.
myHotspots.AddHotspot(KayakHotSpot);
//Save the new custom hotspots file
string path = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\Hotspots Maps\myHotspots.xhs";
myHotspots.SaveAs(path);
}
//Enable and configure hotspots.
myHotspots.HotSpotsEnabled = true;
myHotspots.HotSpotStyle = HotspotStyleOption.Outline;
myHotspots.HotSpotsVisible = true;
myHotspots.ApplyCurrentHotspots();
Console.ReadKey();
}
}
}
|
Add a hotspot |
Copy Code
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using Attachmate.Reflection.UserInterface;
using Attachmate.Reflection.Emulation.OpenSystems;
using Attachmate.Reflection.Framework;
namespace HotSpotsOS
{
class Program
{
static void Main(string[] args)
{
//Start a visible instance of Reflection or get the instance running at the given channel name
Application app = MyReflection.CreateApplication("myWorkspace", true);
//Create a terminal from the session document file and make the session visible
string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\";
ITerminal terminal = (ITerminal)app.CreateControl(sessionPath + "demoSession.rdox");
IFrame frame = (IFrame)app.GetObject("Frame");
frame.CreateView(terminal);
//Get a handle to the HotSpots object
IScreen screen = terminal.Screen;
IHotSpots myHotspots = screen.HotSpots;
//Load the custom hotspots file if it exists. If not, create it.
if (File.Exists(sessionPath + @"Hotspots Maps\myHotspotsOS.xhs") == true)
{
myHotspots.ConfigureHotSpots(sessionPath + @"Hotspots Maps\myHotspotsOS.xhs");
Console.WriteLine("loaded");
}
else
{
//Set up an action sequence to create an email when the hotspot is clicked
InputMapAction actionToCreateEmail = new InputMapAction(InputMapActionID.EmailMessageAction, null);
InputMapActionSequence sequence = new InputMapActionSequence();
sequence.Add(actionToCreateEmail);
//Add the hotspots to the default session hotspots map.
Hotspot sessionHotSpot = new Hotspot("XYZ", sequence);
myHotspots.AddHotspot(sessionHotSpot);
//Save the new custom hotspots file
string path = sessionPath + @"Hotspots Maps\myHotspotsOS.xhs";
myHotspots.SaveAs(path);
}
//Enable and configure the hotspots.
myHotspots.HotSpotsEnabled = true;
myHotspots.HotSpotStyle = HotspotStyleOption.Button;
myHotspots.HotSpotsVisible = true;
myHotspots.ApplyCurrentHotspots();
Console.ReadKey();
}
}
}
|
To test this project
- Press F5 to run the sample
- When the session opens, enter any credentials to log on to the demo.
- Enter the command to navigate to the data:
For an Open System project, enter the "demodata" command.
For an IBM project, enter the "kayak" command.
- Verify that the screen has the hotspot:
For an Open Systems project, double-click the XYZ text and verify that an email is created.
For an IBM project, double-click the KAYAK text and verify that an email is created.
Load a Hotspots File for a Specific Screen or Command
This sample shows how to load a hotspots file when a certain screen is ready or when a specific command is entered.
To load a hostspots file
-
Open the Reflection 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\Reflection.)
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.
- In Visual Studio, create a new Console Application project and add references for the following Reflection assemblies. (Depending on your version of Visual Studio, these can be found either on the .NET tab or under Assemblies | Extensions.)
Attachmate.Reflection
Attachmate.Reflection.Framework
Attachmate.Reflection.Emulation.IbmHosts (if you're using IBM)
Attachmate.Reflection.Emulation.OpenSystems (if you're using UNIX or OpenVMS)
- Replace all the code in the Program.cs file with the following code for the terminal you are using.
Load a hotspots file for a specific screen or command |
Copy Code
|
using System;
using System.Collections.Generic;
using System.Text;
using Attachmate.Reflection.Framework;
using Attachmate.Reflection.Emulation.IbmHosts;
using Attachmate.Reflection.UserInterface;
using Attachmate.Reflection;
namespace Hotspots
{
class Program
{
static void screen_NewScreenReady(object sender, EventArgs e)
{
//Get a handle to the screen Hotspots object
IIbmScreen screen = (IIbmScreen)sender;
IHotSpots myHotspots = (IHotSpots)screen.HotSpots;
//Get a string at a screen position that has some unique text on the screen we want to apply the hotspot on
string screenID1 = screen.GetText(1, 39, 5);
//For the screen that has the KAYAK text, load the custom myHotspots.xhs file
if (screenID1 == "KAYAK")
{
string path = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\Hotspots Maps\myHotspots.xhs";
myHotspots.ConfigureHotSpots(path);
myHotspots.ApplyCurrentHotspots();
}
else
{
//For other screens, load the default Hotspot file
Console.WriteLine(myHotspots.DefaultHotspotMapName);
myHotspots.ConfigureHotSpots(@"C:\Program Files (x86)\Micro Focus\Reflection\Built-Ins\Keyboard Maps\Default 3270.xhs");
myHotspots.ApplyCurrentHotspots();
}
}
static void Main(string[] args)
{
//Start a visible instance of Reflection or get the instance running at the given channel name
Attachmate.Reflection.Framework.Application app = MyReflection.CreateApplication("myWorkspace", true);
//Create a terminal for an Ibm 3270 session and a view to make the session visible
string sessionFilePath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\";
IIbmTerminal terminal = (IIbmTerminal)app.CreateControl(sessionFilePath + "demoSession.rd3x");
IFrame frame = (IFrame)app.GetObject("Frame");
frame.CreateView(terminal);
//Use the NewScreenReady event to identify the screen that uses the custom hotspot file
IIbmScreen screen = terminal.Screen;
screen.NewScreenReady += screen_NewScreenReady;
//Enable Hotspots and configure Hotspot settings
screen.HotSpots.HotSpotsEnabled = true;
screen.HotSpots.HotSpotStyle = HotspotStyleOption.Outline;
screen.HotSpots.HotSpotsVisible = true;
screen.HotSpots.ApplyCurrentHotspots();
Console.ReadKey();
}
}
}
|
Load a hotspots file for a specific screen or command |
Copy Code
|
using System;
using System.Collections.Generic;
using System.Text;
using Attachmate.Reflection.Framework;
using Attachmate.Reflection.Emulation.OpenSystems;
using Attachmate.Reflection.UserInterface;
using Attachmate.Reflection;
namespace Hotspots
{
class Program
{
static void screen_ControlKeySending(object sender, ControlKeySendingEventArgs e)
{
//Get a handle to the screen Hotspots object
IScreen screen = (IScreen)sender;
IHotSpots myHotspots = (IHotSpots)screen.HotSpots;
//Get the text on the cursor row that includes the command that is sent
string screenID1 = screen.GetText(screen.CursorRow, 1, 40);
Console.WriteLine(screenID1);
//For the command that has the demodata text, load the custom myHotspotsOS.xhs file
//For other screens, load the default Hotspot file
if (screenID1.Contains("demodata"))
{
string path = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\Hotspots Maps\myHotspotsOS.xhs";
myHotspots.ConfigureHotSpots(path);
myHotspots.ApplyCurrentHotspots();
}
else
{
string pathToDefault = @"C:\Program Files (x86)\Micro Focus\Reflection\Built-Ins\Keyboard Maps\Default 3270.xhs";
myHotspots.ConfigureHotSpots(pathToDefault);
myHotspots.ApplyCurrentHotspots();
}
}
static void Main(string[] args)
{
string sessionFilePath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\";
//Get a handle to Reflection if it is running or create a new instance if not and make it visible.
Attachmate.Reflection.Framework.Application reflectionApplication = MyReflection.CreateApplication("myWorkspace", true);
//Create a terminal for a session and a view to make the session visible
ITerminal terminal = (ITerminal)reflectionApplication.CreateControl(sessionFilePath + "demoSession.rdox");
IFrame frame = (IFrame)reflectionApplication.GetObject("Frame");
frame.CreateView(terminal);
//Handle the ControlKeySending event to identify the screen with the hotspot
IScreen screen = terminal.Screen;
screen.ControlKeySending += screen_ControlKeySending;
//Enable Hotspots and configure Hotspot settings
screen.HotSpots.HotSpotsEnabled = true;
screen.HotSpots.HotSpotStyle = HotspotStyleOption.Button;
screen.HotSpots.HotSpotsVisible = true;
screen.HotSpots.ApplyCurrentHotspots();
Console.ReadKey();
}
}
}
|
To test this project
- Press F5 to run the sample
- When the session opens, enter any credentials to log on to the demo.
- Open the Reflection Document Settings window and select Manage HotSpots.
- In the Manage Hotspots dialog box, verify that the currently selected hotspot file is the default hotspots file.
- Enter one of the following commands to navigate to the data:
For an Open System project, enter the "demodata" command.
For an IBM project, enter the "kayak" command.
- Open the Manage Hotspots dialog box and verify that the currently selected hotspot file is the myHotspots.xhs file.