Register forum user name Search FAQ

MUSHclient scripting

Description of MUSHclient world function: world.Accelerator


Name Accelerator
Type Method
Summary Add or modify an accelerator key (keystroke to command mapping)
Prototype long Accelerator(BSTR Key, BSTR Send);
Description

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

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 two arguments, the keystroke to add or amend, and the text to be sent. The text is sent to the MUSHclient command processor, and can thus contain aliases, speedwalks, script commands, or anything you might normally type into the command window.

For example, to execute a script simply prefix the script command with the scripting prefix. Or alternatively, make up a word you wouldn't normally type (like "SFDSHHG$%(&") and make an alias to match that. Then in the alias do whatever you want to do.

See also AcceleratorTo which lets you specify where to send the command (eg. script, speedwalk).

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
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

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:

Alt+Down
Shift+Ctrl+F2
Ctrl+N
PageUp
Ctrl+PageUp
F5
Ctrl+Shift+F9

--------

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

Accelerator "Ctrl+K", "" ' 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, or make a "do nothing" alias, and call that. eg.

Accelerator "Ctrl+K", "/" ' execute empty script
Accelerator "Ctrl+K", "DO_NOTHING_ALIAS" ' call an alias that does nothing

The "do nothing" alias might be the safer approach, in case someone has changed the scripting prefix to something other than "/".


----------

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: Available in version 3.53 onwards.


VBscript example
Accelerator "Ctrl+K", "kill"
Accelerator "Ctrl+F", "follow"
Accelerator "Ctrl+E", "eat meat"
Accelerator "Alt+F2", "/Note ""oops"""
Jscript example
Accelerator ("Ctrl+K", "kill")
Accelerator ("Ctrl+F", "follow")
Accelerator ("Ctrl+E", "eat meat")
Accelerator ("Alt+F2", "#4s 3e")  // speedwalk
PerlScript example
$world->Accelerator ("Ctrl+K", "kill")
$world->Accelerator ("Ctrl+F", "follow")
$world->Accelerator ("Ctrl+E", "eat meat")
$world->Accelerator ("Alt+F2", "#4s 3e")  # speedwalk
Lua example
Accelerator ("Ctrl+K", "kill")
Accelerator ("Ctrl+F", "follow")
Accelerator ("Ctrl+E", "eat meat")

-- execute a script
Accelerator ("Ctrl+M", "/DoCommand 'preferences'")

Accelerator ("Ctrl+E", "") -- revert to original behaviour for Ctrl+E
Returns eBadParameter - the keystroke combination was not accepted
eOK - added OK
Introduced in version 3.53

See also ...

Function Description
AcceleratorList List defined accelerators
AcceleratorTo Add or modify an accelerator key - with "Send To" parameter

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

[Back]

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