AGIPCEXP | The Button Tool

Driving STK from a TCP/IP Socket

One option for driving STK from an external script or application is to communicate with the application via a TCP socket.

Assuming you have the appropriate license, STK opens a socket connection at port 5001 by default. If you have several instances of STK running, the first one would receive data through port 5001, the second through port 5002, and so on. You can, however, change the default socket (5001) using the application options in STK user interface or programmatically. When the specified port is opened, STK "listens" for Connect commands.

Connect commands are strings that are then sent to STK for interpretation through the socket connection. The protocol used for the socket communication is described in the Connect help system. In summary the socket communication with STK can be synchronous or asynchronous (i.e. driven by STK internal events). For each command STK will return an successful acknowledgement (ACK) or failure (not) acknowledgement (NACK). To facilitate integration into 3rd party code, AGI provides several client-side implementation of this protocol (see AgConnect library and perl module).

Several client utilities are also installed with STK.


AGIPCEXP.exe is a simple program that is installed with STK, which provides an Internet standard protocol for remote terminal connection service similar to TELNET. It can be used to send individual commands one at a time, but it will also accept a filename as input. The file referenced can contain a series of Connect commands, which will be executed in the order that they are arranged in the file. This can be very useful in automating repetitive tasks.

In the example pictured below the AGIPCEXP utility was used to connect to a running instance of STK, create a new scenario, list the content of the scenario and then close the scenario. Commands are being passed to STK by manually typing them one at a time.

There are a few things to remember when using AGIPCEXP to communicate with STK.

The AGIPCEXP utility is installed with STK, and is located in the <STK install folder>\bin directory, typically:

C:\Program Files\AGI\STK 11\bin\AGIPCEXP.exe

The Button Tool

The Button Tool is another utility, installed with STK, that can be used to organize Connect commands and execute them at the click of a button, hence the name "Button Tool". This utility is a simple program written in Perl with a graphical user interface that allows you to execute actions in STK using Connect commands. You can create buttons using available tools or manual edits to the Button Tool file (*.btip) and then save it to a file for future use. Once a button is created, it can be associated with one or more Connect commands, text strings, or system calls. Help for creating and adding buttons to the button tool is available from the Help menu on the Button Tool interface.

The Button Tool combines the functionality of a command entry window like AGIPCEXP and the automation that can be achieved using a script. It can be very useful for executing repetitive tasks and eliminating typographical errors in command syntax.

The Button Tool utility is installed with STK. The actual utility (ButtonTool.exe), Perl source code for the Button Tool, and sample BTIP files are located in Connect area of the <STK install folder>, typically:

C:\Program Files\AGI\STK 11\Connect\Button_Tool\bin\PC\ButtonTool.exe

Related Topics:

STK 11.2.1 Programming Interface