[Home] [Downloads] [Search] [Help/forum]

MUSHclient scripting

Description of MUSHclient world function: world.AcceleratorTo

Name AcceleratorTo
Type Method
Summary Add or modify an accelerator key - with "Send To" parameter
Prototype long AcceleratorTo(BSTR Key, BSTR Send, short SendTo);

View list of data type meanings


This lets you add or amend the behaviour of MUSHclient "accelerator" keys. For example, you could make Ctrl+E become "eat meat".

This is similar to the Accelerator function (see elsewhere), however this version allows you to specify where the "send text" is to be sent to (for example, to a script, to a speedwalk, to the output window).

These changes only apply to the current world (the one the script function is run in). They override any existing macros or accelerator keys defined for MUSHclient's default behaviour.

You specify three arguments, the keystroke to add or amend, the text to be sent, and where to send it.

The keystroke consists of this syntax:

CTRL + ALT + SHIFT + key

The modifiers CTRL, ALT and SHIFT are all optional, and are not case-sensitive. They can appear in any order.

The key can be one of the following:

0 1 2 3 4 5 6 7 8 9

Accept Add Apps Attn Backspace Cancel Capital Clear Control Convert Crsel Decimal Delete Divide Down End Enter Ereof Esc Execute Exsel F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 Final Hangeul Hangul Hanja Help Home Insert Junja Kana Kanji LButton LControl LMenu LShift LWin Left MButton Menu ModeChange Multiply NonConvert Noname Numlock Numpad0 Numpad1 Numpad2 Numpad3 Numpad4 Numpad5 Numpad6 Numpad7 Numpad8 Numpad9 Oem_clear Pa1 PageDown PageUp Pause Play Print ProcessKey RButton RControl RMenu RShift RWin Right Scroll Select Separator Snapshot Space Subtract Tab Up Zoom

They are not all guaranteed to work in the way you might expect. These names were obtained from the Windows include files. Some keys may be trapped by the operating system, or not be available on your PC.

Reasonable values to use would be things like:



The "SendTo" argument specifies where the text is to be sent to. It can be one of:

0: World
1: Command window
2: Output window
3: Status line
4: Notepad (new)
5: Notepad (append)
6: Log File
7: Notepad (replace)
8: Command queue
9: Send To Variable
10: Execute (re-parse as command)
11: Speedwalk (send text is speedwalk, queue it)
12: Script (send to script engine)
13: Immediate (send to world in front of speedwalk queue)
14: Script - after omit (send to script engine, after lines have been omitted)

The case "set variable" is not very useful because there is no way of specifying which variable to send to.

Use "send to script" if you want to set a variable (using the SetVariable function).


To disable a previously-assigned accelerator, call this function with an empty string as the command. eg

AcceleratorTo ("Ctrl+K", "", 0) -- return to default behaviour

If you wanted to make a key simply "do nothing" then you will need to do something like send an empty script. eg.

AcceleratorTo ("Ctrl+K", "--", 12) -- execute script with only a comment in it (Lua in this case)


To see the name for a particular keypress use the Input menu -> Key Name dialog. This lets you type a key and have its name displayed. This name can then be used in this function.

Note: If you use AcceleratorTo inside a plugin, that plugin ID is remembered and becomes the current plugin (if possible) when the accelerator is pressed. Thus send-to-script is executed in the calling plugin's script space. If the plugin does not exist when the accelerator is pressed (eg. the plugin has been removed) then the accelerator does nothing. However send-to-execute works whether or not the original plugin still exists, for backwards compatibility with the original Accelerator function.

Note: Available in version 4.27 onwards.

VBscript example
AcceleratorTo "Ctrl+K", "kill", 0
AcceleratorTo "Ctrl+F", "follow", 0
AcceleratorTo "Ctrl+E", "eat meat", 0
AcceleratorTo "Alt+F2", "Note ""oops""", 12
Jscript example
AcceleratorTo ("Ctrl+K", "kill", 0)
AcceleratorTo ("Ctrl+F", "follow", 0)
AcceleratorTo ("Ctrl+E", "eat meat", 0)
AcceleratorTo ("Alt+F2", "4s 3e", 11)  // speedwalk
PerlScript example
$world->AcceleratorTo ("Ctrl+K", "kill", 0)
$world->AcceleratorTo ("Ctrl+F", "follow", 0)
$world->AcceleratorTo ("Ctrl+E", "eat meat", 0)
$world->AcceleratorTo ("Alt+F2", "4s 3e", 11)  # speedwalk
Lua example
AcceleratorTo ("Ctrl+K", "kill", sendto.world)
AcceleratorTo ("Ctrl+F", "follow", sendto.world)
AcceleratorTo ("Ctrl+E", string.rep ('-', 60), sendto.output)  -- 60 hyphens in output window

-- execute a script
AcceleratorTo ("Ctrl+M", "DoCommand 'preferences' ", sendto.script)  -- send to script

AcceleratorTo ("Ctrl+E", "") -- revert to original behaviour for Ctrl+E
Lua notes
The "SendTo" field can be specified using the "sendto" table in the Lua global address space, as follows:

sendto.world = 0
sendto.command = 1
sendto.output = 2
sendto.status = 3
sendto.notepad = 4
sendto.notepadappend = 5
sendto.logfile = 6
sendto.notepadreplace = 7
sendto.commandqueue = 8
sendto.variable = 9
sendto.execute = 10
sendto.speedwalk = 11
sendto.script = 12
sendto.immediate = 13
sendto.scriptafteromit = 14
Returns eBadParameter - the keystroke combination was not accepted
eOptionOutOfRange - the SendTo parameter was out of range
eOK - added OK

View list of return code meanings

Introduced in version 4.27

See also ...

Function Description
Accelerator Add or modify an accelerator key (keystroke to command mapping)
AcceleratorList List defined accelerators

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.

Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes

Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes

View all functions


Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]