Script syntax

Configuration in detail

Events, hooks, actions
Plugins
Priorities of hooks


Symbol '#' - comments

Loading plugin:
<PluginName> = load( "<dir\plugin.dll>" [, "<event_type>"] )

Example:
Keyboard = load( "Keyboard\Keyboard.dll", "KEY" )

Include script file:
include( "<script.scs>" )

Example:
include( "winamp.scs" )

Group/Hooks/Actions declaration:

<GroupName> = group( [<enabled>] ){
<hook_name> = hook( "<event_type>", "<event_id>" | *, <enabled> [, <continue> [, <priority>]] ){
...
<variable1> = <plugin_name>.<function>( [<params>] )
...
<command>( [<params>] )
...
}
OnHookEnable( <hook_name> ){
...
}
OnHookDisable( <hook_name> ){
...
}
OnGroupEnable(){
...
}
OnGroupDisable(){
...
}
}

Note:

<enabled> : true/enabled | false/disabled - set default status
<continue> : true/continue | false/stop/break - continue process hooks chain for specified event
<priority> : Hook priority in chain for specified event, default 128
<hook_name> : can be used as variable inside current hook
* : any event ID

Example:

Main = Group( Enabled ){
OnGroupEnable(){
PlaySnd.ActionPreset( OnStart )
}

OnGroupDisable(){
PlaySnd.ActionPreset( OnStop )
}

WinampKey = Hook( "KEY", "Ctrl+Alt+W", Enabled, Break ){
EventSend( "AUDIO", "WINAMP" )
}
}

Commands:

GroupEnable( <group_name> )
GroupDisable( <group_name> )
HookEnable( <group_name>, <hook_name> )
HookDisable( <group_name>, <hook_name> )
HookBreak( <group_name>, <hook_name> )
EventSend( "<event_type>", "<event_id>" | * [, <param>] )
Break( [<condition>] )
SkipN( [<condition>] )
Skip( N, [<condition>] )

Note:

N > 0
<condition> : <expression1> <relational> <expression2>
<expression> : <variable> | number
<relational> : < <= > >= = == <> !=

Plugin functions:

Start()
StartManual( "<id>", "<param>" )
StartPreset( <preset_name> )

Stop()
StopManual( "<id>" )
StopPreset( <preset_name> )

ActionPreset( <preset_name> )
ActionManual( "<param1>" [, "<param2>" [...]] )

Allowable parameters:
* - current event ID (string)
"any string"
integer value (example: -3, 0, 1)
Variable
@N - extended event parameter 0 < N < 4

Example:

Mixer = Group( Enabled ){
VolumeUp = Hook( "REMOTE", "VOL_UP", Enabled, Break ){
Break( VolumeUp < 0 )
v = SndMixer.ActionPreset( VolumeUp )
OSD.ActionManual( "Vol %d %%", v )
}
}


Configuration in detail

Events, hooks, actions

Scripts can be edited manually (Script tab) or with the help of the Wizard (Wizard tab).
If in a script there are errors, the Wizard is not available before their correction.

The main script is in a file main.scs, other files of scripts may be connected by command include, for example:

include( "remote.scs" )

Each event has type, the identifier and parameter.
For example pressing of the button on Remote Control has type "REMOTE", the identifier - the name of the button, parameter - by pressing 0, further - number of repetition and -1 at release. That is by pressing button Play on Remote Control we shall receive some events:

REMOTE, PLAY, 0
REMOTE, PLAY, 1
REMOTE, PLAY, 2
REMOTE, PLAY, -1

To process event it is necessary to set a hook. The hook should be in group. Groups are necessary to quickly disable some hooks simultaneously. An example:

MyGroup = Group( Enabled ){
MyHook = Hook( "REMOTE", "PLAY", Enabled ){
# any actions
}
}

Here group MyGroup is enabled at start of a script (parameter Enabled). The hook MyHook is also enabled (3-rd parameter is equal Enabled) at start of script and reacts to button PLAY on Remote Control.

Inside group there may be special hooks reacting to enabling / disabling of group or separate hook:

MyGroup = Group( Enabled ){
OnGroupEnable(){
# any actions
}
OnHookEnable(MyHook){
# any actions
}
MyHook = Hook( "REMOTE", "PLAY", Enabled ){
# any actions
}
} # end of group

Actions may be calls of functions from plugins (external) or commands of conditional transition, enabling / disabling of groups and hooks, generation of event (internal). At execution of actions their result can be stored in a variable and further to use as parameter in other actions. At interception of event by a hook the parameter of event will be stored in a variable with a name, appropriate to a name of a hook. For example:

MyGroup = Group( Enabled ){
MyHook = Hook( "REMOTE", "PLAY", Enabled ){
OSD.ActionManual("Play %d", MyHook)
}
}

By pressing Play button on Remote Control hook MyHook works, the parameter will be sored in MyHook variable. On the screen it is displayed "Play 0 ", " Play 1 ", " Play 2 " and " Play-1 " at release button. Example of use of several variables:

MyGroup = Group( true ){
MyHook = Hook( "REMOTE", "PLAY", Enabled ){
Break(MyHook<>0)
h = Winamp.ActionManual( "GET_HANDLE" )
Skip2( h <> 0 )
e = ExecFile.ActionManual( "C:\Program Files\Winamp\Winamp.exe" )
Break( e = 0 )
Winamp.ActionManual( "BUTTON1" )
}
}

Plugins

Before to use plugins, they need to be loaded by command Load. This command may be anywhere in the text of a script, but it is necessary before use of the plugin (in the best way in the first lines). For example:

ExecFile = Load( "ExecFile\ExecFile.dll" )

That the plugin began to generate events, it needs not only to be loaded but also to start. For this purpose functions Start, StartManual or StartPreset are used. In different plugins different combinations of these functions may be available. For example:

Keyboard.Start()
WinMon.StartPreset("WINAMP")
Timer.StartManual( "TIMER1", "TIMER", 5 )

Use Event Preset Setup on Plugins tab to configure preset "WINAMP"

Use OnGroupEnable or OnHookEnable to start event plugins. For example:

AlwaysKeyMouse = group( Enabled ) {
OnGroupEnable(){
Keyboard.Start()
}
}

Priorities of hooks

<hook_name> = hook( "<event_type>" | *, "<event_id>" | *, <enabled>, <continue> [, <priority>] ) { ... }

Note:
<enabled> : true | false - set default status
<continue> : true | false - continue process hooks chain for specified event
<priority> : Hook priority in chain for specified event, default 128

Example:

MyGroup = Group( true ){
MyHook1 = Hook( "REMOTE", "PAUSE", Enabled ){
OSD.ActionManual( "Pause OK" )
}
MyHook2 = Hook( "REMOTE", "PAUSE", Disabled, Break, 20 ){
}
MyHook3 = Hook( "REMOTE", "PLAY", Enabled ){
HookEnable(MyGroup, MyHook2)
}
MyHook4 = Hook( "REMOTE", "STOP", Enabled ){
HookDisable(MyGroup, MyHook2)
}
}

At start of a script hook MyHook2 is disabled. By pressing on Remote Control Pause button, "Pause OK" will be displayed. After pressing Play button hook MyHook2 will activated. It priority equal 20, that is has less than at MyHook1 (by default 128), therefore it is processed earlier. In it there are no actions, but is specified to forbid the further processing event by other hooks (4-th parameter is equal Break). Thus by pressing button Pause hook MyHook1 will not work any more though remain enabled. By pressing on Remote Control Stop button will be worked with hook MyHook4 and will switch off hook MyHook2. After that hook MyHook1 again will begin to react to Pause button. By this principle HOLD mode in a script remote.scs is realized.