I have been playing with Crimson Editor, making it the default program for editing MUSHclient scripts. However I found to my annoyance that when I pressed Ctrl+Shift+H although Crimson Editor opened the script file, the program was not brought to the foreground, so that it was an extra step to click on it, to edit the file.
I couldn't find an easy way around this - it seems that the code used inside Crimson Editor to prevent multiple copies being active at once does not correctly bring the program to the front if it was already running.
Thus, I have written a small DLL that you can download and use with MUSHclient. It exposes a couple of handy utilities:
The DLL, and its source code, can be downloaded from:
http://www.gammon.com.au/files/mushclient/lua5.1_extras/windows_utils.zip
File size: 27 Kb.
Inside are windows_utils.dll and windows_utils.c.
Put windows_utils.dll into the same directory as MUSHclient.exe.
To make it work for me I edited the Lua "sandbox" in the Global Preferences, and added these lines *before* the call to MakeSandbox (near the top in other words):
What this does is load the DLL, and then use the Accelerator script command to change the accelerator for editing the script file (Shift+Ctrl+H) to:
If you want to use this with a different editor, just change the words "Crimson Editor" to something else (eg. UltraEdit). The match is case-sensitive on the start of the title of the window.
The other utility in the DLL is an interface to the ShellExecute operating system function. This lets you open, explore or print documents or programs. For example:
Warning - this could be misused if you ran untrusted plugins or scripts. If this is likely to happen I suggest you put this line into your Lua sandbox to disable it:
You would do this after the line:
I couldn't find an easy way around this - it seems that the code used inside Crimson Editor to prevent multiple copies being active at once does not correctly bring the program to the front if it was already running.
Thus, I have written a small DLL that you can download and use with MUSHclient. It exposes a couple of handy utilities:
- windows_utils.send_to_front - bring a program to the front
- windows_utils.shell_execute - uses the Windows shell to run a program, open a file, print it, etc.
The DLL, and its source code, can be downloaded from:
http://www.gammon.com.au/files/mushclient/lua5.1_extras/windows_utils.zip
File size: 27 Kb.
Inside are windows_utils.dll and windows_utils.c.
Put windows_utils.dll into the same directory as MUSHclient.exe.
To make it work for me I edited the Lua "sandbox" in the Global Preferences, and added these lines *before* the call to MakeSandbox (near the top in other words):
assert (package.loadlib ("windows_utils.dll", "luaopen_windows_utils")) ()
Accelerator ("Shift+Ctrl+H",
[[/DoCommand "EditScriptFile"
windows_utils.send_to_front "Crimson Editor"]])
What this does is load the DLL, and then use the Accelerator script command to change the accelerator for editing the script file (Shift+Ctrl+H) to:
- DoCommand "EditScriptFile" -- this still edits the script file
- windows_utils.send_to_front "Crimson Editor" -- this brings Crimson Editor to the front
If you want to use this with a different editor, just change the words "Crimson Editor" to something else (eg. UltraEdit). The match is case-sensitive on the start of the title of the window.
The other utility in the DLL is an interface to the ShellExecute operating system function. This lets you open, explore or print documents or programs. For example:
assert (windows_utils.shell_execute ("c:\\mushclient\\worlds\\SMAUG.MCL"))
Warning - this could be misused if you ran untrusted plugins or scripts. If this is likely to happen I suggest you put this line into your Lua sandbox to disable it:
windows_utils.shell_execute = nil
You would do this after the line:
assert (loadlib ("windows_utils.dll", "luaopen_windows_utils")) ()