0 votes
by (160 points)
edited

The app I'm working on requires that the last thing it does is sends 2 escape keys. I have tried

 dim myByte as byte = "27"
 terminal.sendtoserver(myByte,0)

and

terminal.SendToServer(New ConsoleKeyInfo("\0", ConsoleKey.Escape, False, False, False))

and

terminal.SendToServer(New ConsoleKeyInfo("", ConsoleKey.Escape, False, False, False))

all 3 with and without

    Do
        state = terminal.Process(500)
    Loop While state = TerminalState.DataReceived

in between the 2 escape keys. Methods 1 and 3 are typing the escape key unicode sequence instead of sending as a key press, depending on the function key mode set (Linux, LinuxAlternative, Common, XtermR6, all work for the F-keys that the app uses) either as "0[21~" or "[21~", after the second escape key is sent. Method 2 is writing "" to the screen for both key presses.

2 Answers

0 votes
by (73.5k points)
edited

You were quite near. The code should look like this:

terminal.SendToServer(New ConsoleKeyInfo(Chr(27), ConsoleKey.Escape, False, False, False))

It is because the ConsoleKey.Escape value is not handled by the terminal explicitly, so the ConsoleKeyInfo.KeyChar is used. Actually, it is easy to handle ConsoleKey.Escape in terminal, so I will add this functionality. All your cases will work in the next release.

Basically, you want to send a string which contains two escapes. The easiest way is the following:

VB .NET

terminal.SendToServer(Chr(27) & Chr(27))

C#

terminal.SendToServer("\x1B\x1B");
0 votes
by (15.2k points)
edited

Hi, we have just release new Scripting API in 2014-R2 release. You can read more of its features on Scripting features page.

...