STK ButtonTool

The ButtonTool is a Perl script with a graphical user interface (GUI) that you can use to associate STK Connect commands with buttons. You can create these buttons dynamically and then save them to a file for future use. You can also associate a text string with a button, so that it pastes the string into the command text field. Finally, you can also associate a system call with a button.

The ButtonTool is much like a "macro" tool. You can use it to produce buttons that condense mutiple interactions with STK into a single operation. For example, you can create a single button that affects the graphics properties of all sensors in STK. Or, if you often generate the same report for a scenario, you can create a button that produces that report.

Installed location

The ButtonTool application is installed with STK in the Connect folder:

<STK install folder>\Connect\Button_Tool

The Button_Tool folder contains a bin subfolder with the executable file and the Perl source code.

To modify and use the STK ButtonTool source code, you must first install Perl and the Tk module. ActivePerl for Windows is available from the ActiveState website. The Tk module is available from the CPAN website. Copy Stk.pm from <STK install folder>/CodeSamples/CodeSamples.zip to your .../Perl/lib folder or keep it in the save folder with the ButtonTool.pl Perl file.

Definitions

Item Description
Command (CMD) Buttons Buttons associated with connect commands (have a raised appearance)
Command (TGL) Buttons Buttons associated with toggled connect commands (have a raised appearance, white color)
System (SYS) Buttons Buttons associated with system commands (have a raised groove)
Constants (TXT) Buttons Buttons associated with constant strings (have a recessed groove)

User interface

The Button Tool's user interface comprises three menus, the Command field, and the Output window.

Menus

File menu

Function Description
Open Open a file to load a previously saved command file. In Windows, this function is typically associated with the .btip file format.
Reload Reopen the file.
Open In Editor Open the file in an editor program.
Save/Save As... Save the buttons to a file.
Save Output Window Save the contents of the output window to a file.
Quit

Close the connection to STK and the ButtonTool application.

View menu

Function Description
Flip Command Buttons Change the orientation of the Command buttons (vertical or horizontal).
Toggle Constants Buttons Toggle the appearance of the Constants buttons.
Toggle Command Window Toggle the appearance of the Command Window.
Toggle Output Window Toggle the appearance of the Output Window.
Stored Views Window Open a dialog that you can use to select a stored view in STK.
Output Command History Print the command history to the Output Window.
Clear Output Window Clear the contents of the Output Window.
Clear Command History Clear the command history.

Tools menu

Function Description
Connect to STK / Disconnect from STK Toggle a connection to STK. Once a connection has been established, the border of the tool turns from red to green and the text *** Connected *** appears in the title bar of the application.
New Command Button Create a new Command or System button.
New Constants Button Create a new Constant button.
Command Button from Output Window Create a Command button from the contents of the Output Window.

Help menu

The Help menu comprises commands that open this Help topic, the About page, and the Connect section of the STK Help.

Command window

After connecting to STK, you can send Connect commands from the ButtonTool. Enter the command in the Command field and click Send (or press the Return key). You can enter multiple commands in the Command field, each separated by a semicolon. For example:

Animate * Reset; Animate * timestep 10; Animate * Start

You can use the Alt-Right and Alt-Left keyboard combinations to move the insertion cursor to the next or previous semicolon, respectively. These keyboard shortcuts are useful for working with inputs that contain many commands.

Each command line that you send is saved into a command history that you can access using the Up and Down keys. The Up key moves backward through the history while the Down key moves forward. Any text following the last semicolon is deleted and replaced by the command from the history. The command history is also available when you create a New Command Button, after clicking in the Command field.

Each command that you execute is echoed in the Output Window. If STK does not understand a command, it echoes a NACK (No ACKnowledgment) message. If a command returns data, that data is also echoed in the Output Window.

If the first keyword in the command is either sys or system, the command is executed as a system command rather than a Connect command. You can use these keywords to start other scripts or applications directly from the ButtonTool.

Advanced Perl users - if the first keyword in the command is qx, the command is executed using the Perl qx method. The qx method enables the Output window to display the command's output.

Output window

When the Output window is visible, you can resize the ButtonTool by clicking an edge of the window and dragging the mouse. When it is not visible, you cannot resize the ButtonTool. The window will automatically resize itself based on the buttons and command window size.

Click Clear Output to erase all the content displayed in the Output window.

Buttons

The buttons that you define are displayed below the menus. If the tool tips option is turned on, you can see the definition of a button by hovering the cursor over it. You can also right-click on a button to print its definition in the output window.

Command file format

GUI property formatting keywords:

MAXROW::<number of rows> - sets maximum number of Rows before wrapping

MAXCOL::<number of columns> - sets maximum number of Columns before wrapping

BALLOONS::{ ON | OFF} - turns tool tips balloons on or off

BORDERWIDTH::<number> - sets border depth width around the button

FONTSIZE::<number> - sets font size

FONT::<font name> - sets font type

PADX::<number> - sets the pad between text and button outline - x

PADY::<number> - sets the pad between text and button outline - y

AUTOCONNECT::host:port - on load, attempts to connect to host on port

TOPLEFTLOCATION::+<x position>+<y position> - on load, puts the top left corner of the window at <x position>, <y position> (given in pixels)

Command types for buttons: <type>::<button label>::<command/constant>

CMD - STK Connect command, or commands separated by semicolons

TGL - STK Connect command, or commands with double colons separating sets of button names and commands

SYS - system command call

TXT - text to paste in Command field

You can break up a command across several lines of the command file by using the line continuation indicator, ... . For example, the command:

CMD::Load Sat2 & 3::Load / Scenario/stkDemo/Satellite "./Sat2.sa" ;Load / Scenario/stkDemo/Satellite "./Sat3.sa"

can also be formatted as:

CMD::Load Sat2 & 3::...

Load / Scenario/stkDemo/Satellite "./Sat2.sa" ;...

Load / Scenario/stkDemo/Satellite "./Sat3.sa"

When you use the Save or SaveAs commands to save a command file, the lines in the file will be written in a legible format using line continuation. AGI recommends that you use line continuation to add legibility to your command files.

Blank lines appearing in the command file will be ignored, as well as lines that begin with #.

File paths

You can substitute the . wildcard for the path to the button (.btip) file in the STK Connect segment of the Command Button definition. If you copy your button files into the same folder as the scenario where you want to use them, you can then use the . wildcard to reference the scenario and all its objects using a relative path. For example, if a scenario is located in the following folder:

C:\Program Files\AGI\STK 12\Data\DemoScenarios\Communications\sun_rfi\sun_rfi.sc

And you copy a button file to the same folder:

C:\Program Files\AGI\STK 12\Data\DemoScenarios\Communications\sun_rfi\myButton.btip

The ButtonTool will store the path to the *.btip file as:

C:\Program Files\AGI\STK 12\Data\DemoScenarios\Communications\sun_rfi\

If you want to send a command to modify the satellite object, Sat1.sa, you can use the following relative path expression in your button command to identify it:

"./Sat1.sa"

Examples

The STK ButtonTool is installed with three example files in the <STK install folder>\Connect\Button_Tool\bin\PC folder. You can double-click one of the files to open it in the ButtonTool.

Example command formats

CMD::GetEpoch::GetEpoch Scenario/Scenario1

TGL::Load DSP::Load / */Satellite "./dsp.sa"::Unload DSP::Unload / */Satellite/dsp

TXT::Paste::This text gets pasted to command text box

SYS::WordPad::"C:/Program Files/Windows NT/Accessories/wordpad.exe"

SYS::My txt file::notepad ./myFile.txt

SYS commands are run in the background as independent processes, if possible. You do not specify &.

Commands not supported

The following STK Connect commands are not supported by the ButtonTool:

  • ACKOFF
  • ASYNCON
  • ASYNCLATLON
  • ASYNC2DPICK
  • ASYNC3DPICK
  • CONCONTROL (options other than Disconnect and QuitSTK)

Feedback

If you have any questions or comments about the ButtonTool, please contact AGI Technical Support.