Script function
world.DoCommand
Read about scripting
Type
Method
Summary
Queues a MUSHclient menu command
Prototype
long DoCommand(BSTR Command);
View list of data type meanings
Description
Queues an internal MUSHclient command, as if you had selected it from the menu or typed the corresponding keyboard accelerator. This lets you script things that are available from menus but might not be provided for directly in the scripting language (eg. connect to worlds in startup list).
The command is actually entered in the Windows message queue using the PostMessage operating-system call. What this means is that the command you specify is not done immediately, but will be actioned next time through the main "message loop".
The reason for this is that some commands (eg. world.DoCommand "close", or world.DoCommand "ExitClient") would crash the client because the program (or window) would close while the script was still executing. Similarly any command that opened a dialog box would mean that the script would be paused until the dialog box was closed.
That means that this sort of thing will *not* work:
world.DoCommand "copy"
mystring = world.GetClipboard
This is because the copy command is deferred until later, whereas the GetClipboard is executed immediately (as it is an inbuilt script command).
The intention of DoCommand is that you can bind aliases to internal commands, or automate some actions, but not to directly execute MUSHclient actions while a script is running. For instance, you might make an alias:
Alias: #chats
Send: DoCommand "chatsessions"
Send to: Script
To find the current list of commands you can use:
/world.Debug "internal_commands"
Also see world.GetInternalCommandsList to get the list in a script.
The current list is (as at version 3.73):
ASCIIart, About, ActivateInputArea, ActivityList, ActivityToolbar,
ActivityViewCloseWorld, ActivityViewSaveWorld, ActivityViewSaveWorldAs, AltA,
AltB, AltDownArrow, AltJ, AltK, AltL, AltM, AltN, AltO, AltP, AltQ, AltR,
AltS, AltT, AltU, AltUpArrow, AltV, AltX, AltY, AltZ, AlwaysOnTop,
ArrangeIcons, AutoConnect, AutoSay, Base64Decode, Base64Encode,
BookmarkSelection, BugReports, CascadeWindows, ChatSessions,
ClearCommandHistory, ClearOutput, Close, CloseAllNotepadWindows, ColourPicker,
CommandEnd, CommandHistory, CommandHome, CompleteFunction, ConfigureAliases,
ConfigureAutosay, ConfigureChat, ConfigureColours, ConfigureCommands,
ConfigureCustomColours, ConfigureKeypad, ConfigureLogging, ConfigureMacros,
ConfigureMudaddress, ConfigureMxpPueblo, ConfigureNameAndPassword,
ConfigureNotes, ConfigureOutput, ConfigurePasteToWorld, ConfigurePrinting,
ConfigureScripting, ConfigureSendFile, ConfigureTimers, ConfigureTriggers,
ConfigureVariables, Connect, ConnectToAllOpenWorlds,
ConnectToWorldsInStartupList, Connect_Or_Reconnect, ContextHelp,
ConvertHTMLspecial, Copy, CopyAsHTML, CtrlKeypad0, CtrlKeypad1, CtrlKeypad2,
CtrlKeypad3, CtrlKeypad4, CtrlKeypad5, CtrlKeypad6, CtrlKeypad7, CtrlKeypad8,
CtrlKeypad9, CtrlKeypadDash, CtrlKeypadDot, CtrlKeypadPlus, CtrlKeypadSlash,
CtrlKeypadStar, CtrlN, CtrlP, CtrlZ, Cut, DebugIncomingPackets,
DebugWorldInput, DiscardQueuedCommands, Disconnect, DoMapperComment,
DoMapperSpecial, DosToMac, DosToUnix, East, EditScriptFile, End, Examine,
ExitClient, Find, FindAgain, FindNextNotepad, FindNotepad, FlipToNotepad,
Forum, FreezeOutput, FullScreenMode, FunctionList, FunctionsWebPage,
GenerateCharacterName, GenerateUniqueID, GettingStarted, GlobalPreferences,
GlobalReplace, GoToBookmark, GoToLine, GoToMatchingBrace, GoToNotepadLine,
GoToURL, Help, HelpContents, HelpIndex, HighlightWord, Immediate, Import,
Info, InfoBar, InputGlobalChange, InsertDateTime, Keypad0, Keypad1, Keypad2,
Keypad3, Keypad4, Keypad5, Keypad6, Keypad7, Keypad8, Keypad9, KeypadDash,
KeypadDot, KeypadPlus, KeypadSlash, KeypadStar, KeysEscape, KeysTab, LineDown,
LineUp, LogSession, Look, LowerCase, MacToDos, MacroCtrlF1, MacroCtrlF10,
MacroCtrlF11, MacroCtrlF12, MacroCtrlF2, MacroCtrlF3, MacroCtrlF5, MacroCtrlF
6, MacroCtrlF7, MacroCtrlF8, MacroCtrlF9, MacroF1, MacroF10, MacroF11, MacroF
12, MacroF2, MacroF3, MacroF4, MacroF5, MacroF6, MacroF7, MacroF8, MacroF9,
MacroShiftF1, MacroShiftF10, MacroShiftF11, MacroShiftF12, MacroShiftF2,
MacroShiftF3, MacroShiftF4, MacroShiftF5, MacroShiftF6, MacroShiftF7,
MacroShiftF8, MacroShiftF9, MakeMultiLineTrigger, Mapper, Maximize, MinimiseProgram,
Minimize, MudLists, New, NewWindow, NextCommand, NextPane, NoCommandEcho,
North, NotesWorkArea, Open, OpenWorldsInStartupList, PageDown, Pageup, Paste,
PasteFile, PasteToMush, PluginWizard, Plugins, Preferences, PreviousCommand,
Print, PrintNotepad, PrintPreview, PrintSetup, QuickConnect, Quit,
QuoteForumCodes, QuoteLines, RecallText, ReconnectOnDisconnect,
RefreshRecalledData, Register, ReloadDefaults, ReloadNamesFile,
ReloadScriptFile, RemoveBlanks, RepeatLastCommand, RepeatLastWord,
ReplaceNotepad, ResetAllTimers, ResetToolbars, Restore, Save, SaveAs, SaveSelection,
SelectAll, SelectMatchingBrace, SendMailTo, SendToAllWorlds,
SendToCommandWindow, SendToScript, SendToWorld, South, SpellCheck, Start,
StopSoundPlaying, Take, TextAttributes, TileWindows, TileWindowsVertically,
TipOfTheDay, Trace, UnconvertHTMLspecial, Undo, UnixToDos, Up, UpperCase,
UsingHelp, ViewStatusbar, ViewToolbar, ViewWorldToolbar, WebPage, West,
Whisper, WindowsSocketInformation, WordCount, World1, World10, World2, World3,
World4, World5, World6, World7, World8, World9, WrapLines, WrapOutput
Available in MUSHclient version 3.39 onwards.
VBscript example
DoCommand "WindowsSocketInformation"
DoCommand "FullScreenMode"
Jscript example
DoCommand ("WindowsSocketInformation");
DoCommand ("FullScreenMode");
PerlScript example
DoCommand ("WindowsSocketInformation");
DoCommand ("FullScreenMode");
Python example
world.DoCommand ("WindowsSocketInformation")
world.DoCommand ("FullScreenMode")
Lua example
DoCommand ("WindowsSocketInformation")
DoCommand ("FullScreenMode")
Return value
eNoSuchCommand: That command name was not recognised
eOK: Did the command (or attempted to do it)
Note that even if eOK (0) is returned, the command will not necessarily successfully execute. For example, DoCommand "WordCount" would not do anything if a "world" window was active, rather than a notepad window.
View list of return code meanings
See Also ...
Function
(GetInternalCommandsList) Returns a list of the internal MUSHclient command names
(Help topic: function=DoCommand)