Tutorial: Basic TerminalEmulation module utilization

In this guide we are going to utilize the TerminalEmulation module.
BlueZone terminal emulator is utilized (Trial Version) but all should be applicable to the Terminal Emulator of your choice.

We are going to connect to an already existing session, get the text from the screen, sign in using our credentials, sending some keystrokes and finally exiting and closing the session.
Hllapi is utilized.

You can use already existing configurations of your own by using ```TerminalEmulation.OpenSessionUsingReflectionProfile module.
``
As always, best practices are demonstrated.
Always keep in mind that your scripts must be easy to read, maintain and distribute.

Let’s begin…

Begin by starting the Terminal Emulator and creating a session:

First of all you must know the path to Hllapi:
image

Then create a variable to hold the name of the session you are going to connect to:
image
Note that sessions always take single characters in ascending order.
For example the first session is going to be ‘A’, the second ‘B’ etc.

Now it’s time to open the session:
image

Let’s retrieve the text from the emulator and print it in the console:
image

By checking the output we can see the expected text:

In the example we are going to sign in through the use of Robin, thus providing the user name and password.
With the .MoveCursor action we move the cursor to the requisite position, in the BlueZone example that is Row:5, Column: 25 for the user name input and Row:6, Column:25 for the password.
image

Now we can enter the username with the .SetTextOnCursorPosition action:
image

Just to mimic a more natural approach I entered a delay command:
image

Then repeat for the password entry:
image

Send an “Enter” keypress with the .SendKey action to sign-in.
image

You should be presented with the following screen in the BlueZone terminal:

Now we can tamper with the “F” key options that are presented bellow.
Let’s remove all messages, except the unanswered questions (if any), retrieve the text from the emulator and print it in our editors console.
We utilize .SendKey action to use the “F16” option.
image

The emulator output should look like this:

Retrieve the text and print it as output:
image

Output:

To mimic a more natural approach again, give it a 1" delay and utilize the “F3” option to exit/sign out:
image

Finally terminate the session:
image

Note: Never forget to terminate sessions in case there is no further use for them.

Screenshots of the whole script:


image


Be sure to check the following documentation entry(ies): TerminalEmulation

GitHub link

Best regards,
J.


James Papadimitriou
Technical Evangelist

1 Like