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

Accelerator

Script function

world.Accelerator

Read about scripting

Type

Method

Summary

Add or modify an accelerator key (keystroke to command mapping)

Prototype

long Accelerator(BSTR Key, BSTR Send);

View list of data type meanings

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.


Available in MUSHclient 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


Return value

eBadParameter - the keystroke combination was not accepted
eOK - added OK

View list of return code meanings

See Also ...

Topics

Aliases
Keypad navigation
Macro keys

Functions

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

(Help topic: function=Accelerator)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

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.

[Home]


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]