Skip to content

Scripting

The MOAS Client can receive messages from a scripting program. This can be used for various tasks including defining “hot keys” which will select an antenna or turn a rotator. It can also be used to activate the logging program’s entry window (and it will select the active station if SO2R).

All messages are sent using PostMessage or SendMessage and a scripting program must have this capability. PostMessage takes a message number and two numeric arguments. They are directed to a MOAS Client window. SendMessage takes the same arguments but returns a number. It is used for queries.

The Antenna Display, Antenna Selector, and Rotator Direction windows accept messages for scripting. Numbers in messages are zero-based. For example the first antenna in a list is antenna 0 and the top left button is row 0 column 0.

The Antenna Display window accepts five messages.

Message 32768 has no effect on any antennas or rotators. The arguments must be zero. The logging program’s entry window will become active.

Message 32769 returns information about the antenna display window. The first argument describes the information to be returned. The second argument is the section.

These are the possible values for the first argument:

NumberPurpose
0Return the number of sections. The second argument must be zero.
1Return the station number for the specified section.
2Return the radio number for the specified section.
3Return the lower frequency for the specified section.
4Return the upper frequency for the specified section.
5Return the number of antennas displayed in the specified section.
6Return the number of antennas in the specified section.

If an invalid operation or non-existent section is specified the returned value will be 0xFFFFFFFF.

Message 32770 returns the ID of a specific antenna. The first argument is the section. The second argument is the antenna within the section.

If a non-existent section is specified the returned value will be 0xFFFFFFFF. If the antenna does not exist the returned value will be 0xFFFFFFFE.

Message 32771 changes the selected antenna for a radio. The first argument is the section of the window (antenna display can show several sections). The second is the antenna within the section. Both of these start with zero (the first section is zero and the first antenna is zero).

The antenna display will not show all antennas if there are more antennas in a section than the section was configured for. And the display may be set to centre the selected antenna. These are not used to determine which antenna is selected — the number for an antenna within the section will stay the same for an antenna regardless of which is displayed in the window.

This message will select an antenna even if the Antenna Display window will not allow selection by using a mouse.

Message 32772 activates a function, such as swapping antennas or saving the current selection. The first argument is the section of the antenna display window corresponding to the function. Normally this can be zero. The second argument is the ID of the function in the server configuration file.

The Antenna Selector window accepts two messages.

Message 32768 has no effect on any antennas or rotators. The arguments must be zero. The logging program’s entry window will become active.

Message 32769 returns information about the antenna selector window. The first argument describes the information to be returned. The second argument must be zero.

These are the possible values for the first argument:

NumberPurpose
0Return the number of rows and columns. The number returned is the number of rows times 100 plus the number of columns.
1Return the station number.
2Return the radio number.
3Return the lower frequency.
4Return the upper frequency.

If an invalid operation is specified the returned value will be 0xFFFFFFFF.

Message 32770 returns information about the antenna selector button. The first argument describes the information to be returned. The second argument specifies the button as the row times 100 plus the column.

These are the possible values for the first argument:

NumberPurpose
0Return the type of the button, zero if it is an antenna and one if it is a function.
1Return one if this is an additive antenna such as a Yagi in a stack, zero otherwise.
2Return the transmit and receive state. Zero is unavailable, one is available, and two is selected. The returned value is the transmit state times ten plus the receive state.
3Return antenna or function ID.

If an invalid operation is specified or the number of rows or columns is more than the selector contains, the returned value will be 0xFFFFFFFF. If a button does not have an antenna or function the returned value will be 0xFFFFFFFE.

Message 32771 selects transmit and receive antennas or selects a function. The first argument is the transmit antenna or function and the second is the receive antenna.

The antenna or function is determined by the row and column where it appears in the Antenna Selector Window. The number is the row times 100 plus the column plus a modifier as follows:

NumberPurpose
0Select this as the only antenna.
10000If this antenna is part of an additive system (such as an antenna stack) select it in addition to the others already selected. If a different antenna system is selected or this is not part of an additive system then select it as the only antenna.
20000If this antenna is part of an additive system (such as an antenna stack) deselect it if it is selected and if deselecting it would not result in no antennas being selected. Otherwise select it as the only antenna.
30000If this antenna is part of an additive system (such as an antenna stack) select it if it is deselected and deselect it if it is selected (toggle the selection).
40000Do nothing with this antenna (no-op). This is used for the receive antenna if selecting only a transmit antenna or vice-versa.

The Rotator Direction window accepts two messages.

Message 32768 has no effect on any antennas or rotators. The arguments must be zero. The logging program’s entry window will become active.

Message 32769 returns information about the antenna rotator. The first argument describes the information to be returned. The second argument depends on the first.

These are the possible values for the first argument:

NumberPurpose
0Returns the number of rotators displayed by the window. The second argument must be zero.
1Returns the direction of the specified rotator. The argument is the rotator. Zero is the first rotator.

If an invalid operation or rotator greater than the maximum is specified the returned value will be 0xFFFFFFFF. If an unused rotator is specified the returned value may be 0xFFFFFFFE.

Message 32770 sets the direction of one or more rotators. The first argument is the heading. The second argument must be zero.

There are many scripting programs available. These examples use AutoHotkey which is a free scripting language that provides hot key capabilities.

These examples are provided to show how to script the MOAS Client and not as complete examples of AutoHotkey scripts. AutoHotkey has many powerful features and can assign a script to almost any key.

The small station configuration is supplied as an example MOAS configuration. It has an all-band vertical, a triband beam, and dipoles for 40 and 80. There are at most three antennas available on any band. An antenna display with two sections and three antennas in each section will show all choices. The antenna display is named “Antennas”.

The station has one rotator which is in a window named “Rotator”.

Small station antenna display

Small station rotator window

Scripting will be used to select antennas and rotate the triband beam using the keyboard. The script shows the use of the commands to select an antenna and activate a function in a display window and to set a rotator direction.

The logging program does not use the WIN key for any commands. So WIN-F1 through WIN-F12 would be available for antenna and direction control. The assignments will be as follows:

KeyPurpose
WIN-F1Select first antenna in display for Radio 1
WIN-F2Select second antenna in display for Radio 1
WIN-F3Select third antenna in display for Radio 1
WIN-F4Swap the Radio 1 and Radio 2 antennas
WIN-F5Select first antenna in display for Radio 2
WIN-F6Select second antenna in display for Radio 2
WIN-F7Select third antenna in display for Radio 2
WIN-F8Swap the Radio 1 and Radio 2 antennas
WIN-F9Turn tribander to 45 degrees
WIN-F10Turn tribander to 180 degrees
WIN-F11Turn tribander to 270 degrees
WIN-F12Turn tribander to 330 degrees

This is an example script which would implement the above keys using AutoHotkey:

#NoEnv
#Warn
#SingleInstance Force
SendMode Input
SetWorkingDir %A_ScriptDir%
#F1::
PostMessage, 32771, 0, 0, , Antennas
Return
#F2::
PostMessage, 32771, 0, 1, , Antennas
Return
#F3::
PostMessage, 32771, 0, 2, , Antennas
Return
#F4::
PostMessage, 32772, 0, 0, , Antennas
Return
#F5::
PostMessage, 32771, 1, 0, , Antennas
Return
#F6::
PostMessage, 32771, 1, 1, , Antennas
Return
#F7::
PostMessage, 32771, 1, 2, , Antennas
Return
#F8::
PostMessage, 32772, 0, 0, , Antennas
Return
#F9::
PostMessage, 32769, 45, 0, , Rotator
Return
#F10::
PostMessage, 32769, 180, 0, , Rotator
Return
#F11::
PostMessage, 32769, 270, 0, , Rotator
Return
#F12::
PostMessage, 32769, 330, 0, , Rotator
Return

The big station configuration is supplied as an example MOAS configuration. It has vertical four-squares on 160–40 and multiple beams including stacks on 20–10. Two antenna selectors are named “Selector 1” and “Selector 2”.

Big station Selector 1

Big station Selector 2

This script is more complex than the simple station script. The behaviour of the keys depends on the band and which antenna is selected. Pressing a key multiple times can switch between antennas or can activate or deactivate a receiving antenna.

KeyPurpose
WIN-F1Select an antenna for Radio 1. For 80 and 160 select the NE 4-square. Toggle the NE beverage on and off if pressed again. For 40 select the beam. Switch between the beam and NE 4-square if pressed again. For 20–10 select the entire stack. Toggle between receiving on the full stack and only the bottom antenna (useful during rain static) if pressed again.

WIN-F2 through WIN-F4 would select the other 4-square directions and toggle the appropriate receive antennas and would select different stack combinations and the multiplier antenna. This is the part of the script for WIN-F1:

#NoEnv
#Warn
#SingleInstance Force
SendMode Input
SetWorkingDir %A_ScriptDir%
; Commands for Antenna Selector window
global GET_SELECTOR_INFO := 32769
global GET_BUTTON_INFO := 32770
global SELECT_ANT := 32771
; GET_SELECTOR_INFO operations
global GET_SELECTOR_LOWER_FREQ := 3
; GET_BUTTON_INFO operations
global GET_BUTTON_STATE := 2
; Button state
global BUTTON_SELECTED_TX_RX := 22
; Selection modifiers
global SELECTION_NOOP := 40000
; Buttons by row and column
R0C0 := 0
R0C1 := 1
R1C0 := 100
R1C1 := 101
R2C0 := 200
R2C1 := 201
R3C0 := 300
R3C1 := 301
; The antennas on the Selector
global ANT_4SQ_NE := R0C0
global ANT_4SQ_SE := R1C0
global ANT_4SQ_SW := R2C0
global ANT_4SQ_NW := R3C0
global ANT_BEV_NE := R0C1
global ANT_BEV_S := R1C1
global ANT_BEV_W := R2C1
global ANT_40_BEAM := R0C1
global ANT_ALL := R0C0
global ANT_TOP := R1C0
global ANT_MID := R2C0
global ANT_BOT := R3C0
global ANT_MULT := R0C1
; The names of the selector windows for radio 1 and radio 2
RADIO_1_WINDOW := "Selector 1"
RADIO_2_WINDOW := "Selector 2"
DoF1(selector)
{
if !WinExist(selector)
Return
; Get the frequency
SendMessage, GET_SELECTOR_INFO, GET_SELECTOR_LOWER_FREQ, 0
if ErrorLevel = FAIL
Return
frequency := ErrorLevel
if (frequency = 1800) || (frequency = 3500)
{
; See if the NE antenna is selected for transmit and receive
SendMessage, GET_BUTTON_INFO, GET_BUTTON_STATE, ANT_4SQ_NE
if ErrorLevel = FAIL
Return
if (ErrorLevel = BUTTON_SELECTED_TX_RX)
{
; NE is selected, turn on NE beverage
PostMessage SELECT_ANT, SELECTION_NOOP, ANT_BEV_NE
Return
}
; NE not selected or has beverage, select it
PostMessage SELECT_ANT, ANT_4SQ_NE, ANT_4SQ_NE
Return
}
if frequency = 7000
{
; See if the beam is selected
SendMessage, GET_BUTTON_INFO, GET_BUTTON_STATE, ANT_40_BEAM
if ErrorLevel = FAIL
Return
if (ErrorLevel = BUTTON_SELECTED_TX_RX)
{
; Beam is selected, switch to NE 4-square
PostMessage SELECT_ANT, ANT_4SQ_NE, ANT_4SQ_NE
Return
}
; Beam is not selected, select it
PostMessage SELECT_ANT, ANT_40_BEAM, ANT_40_BEAM
Return
}
; 10, 15, 20 all have a three antenna stack
SendMessage, GET_BUTTON_INFO, GET_BUTTON_STATE, ANT_ALL
if ErrorLevel = FAIL
Return
if (ErrorLevel = BUTTON_SELECTED_TX_RX)
{
; Whole stack is selected, receive on lower only
PostMessage SELECT_ANT, SELECTION_NOOP, ANT_BOT
Return
}
; Stack is not selected, select it
PostMessage SELECT_ANT, ANT_ALL, ANT_ALL
Return
}
#F1::
DoF1(RADIO_1_WINDOW)
Return