Reflection .NET API
Attachmate.Reflection.Emulation.OpenSystems Assembly / Attachmate.Reflection.Emulation.OpenSystems Namespace / ITerminal Interface / ConnectAction Property
Example


In This Topic
    ConnectAction Property (ITerminal)
    In This Topic
    Gets or sets a sequence of action(s), such as running a macro, to run automatically after a connection is established.
    Syntax
    'Declaration
     
    
    Property ConnectAction As InputMapActionSequence
    'Usage
     
    
    Dim instance As ITerminal
    Dim value As InputMapActionSequence
     
    instance.ConnectAction = value
     
    value = instance.ConnectAction
    InputMapActionSequence ConnectAction {get; set;}
    Exceptions
    ExceptionDescription
    This exception is thrown if the set parameter is longer than the maximum allowed.
    This exception is thrown when you modify a property that was secured via the Permissions Manager or that can only be modified by an Administrator.
    Remarks
    Connect action sequences run after the terminal has successfully made a connection to the host. They should not include session setup information.
    Example
    This sample opens a session document and assigns a sequence that runs a connection macro to the ConnectAction property. When the session connects or is reconnected, the macro runs.
    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;
            }
        }
    }
    See Also