using System;
using Attachmate.Reflection.Framework;
using Attachmate.Reflection.Emulation.OpenSystems;
using Attachmate.Reflection.UserInterface;
namespace SetConnectionMacro
{
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
string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\test.rdox";
ITerminal terminal = (ITerminal)app.CreateControl(sessionPath);
//Make the session visible in the workspace
IFrame frame = (IFrame)app.GetObject("Frame");
frame.CreateView(terminal);
//Define parameters for the RunMacroAction to run the CopyData macro in the session document's VBA project with no prompt at runtime
object[] parameters = { "Recorded.MyConnectMacro", MacroEnumerationOption.Document, false };
//Create a new action to run a macro with these parameters
InputMapAction action = new InputMapAction(InputMapActionID.RunMacroAction, parameters);
//Create an action sequence and add this action to the sequence
InputMapActionSequence sequence = new InputMapActionSequence();
sequence.Add(action);
//Assign the sequence to the terminal.ConnectAction property
terminal.ConnectAction = sequence;
terminal.RunMacroAtReconnect = true;
}
}
}