Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Lua
➜ A utility to bring Crimson Editor to the foreground
A utility to bring Crimson Editor to the foreground
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Tue 23 May 2006 04:58 AM (UTC) Amended on Wed 04 Jun 2008 09:31 PM (UTC) by Nick Gammon
|
Message
| 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:
- 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")) ()
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rakon
USA (123 posts) Bio
|
Date
| Reply #1 on Tue 23 May 2006 05:11 PM (UTC) |
Message
| Wow, thats nifty Nick. Thanks!
|
Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for. | Top |
|
Posted by
| Norbert
USA (61 posts) Bio
|
Date
| Reply #2 on Tue 19 Sep 2006 11:13 PM (UTC) |
Message
| Is it possible to access the ftp features of Crimson Editor with aliases and a little scripting in mushclient? What I want to do is open a file from the mud I play one for editing. |
Norbert
-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
| Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) Bio
|
Date
| Reply #3 on Thu 21 Sep 2006 02:23 AM (UTC) |
Message
| One note with this.. The "FindWindow" API, which seems to be what he is using (just a guess, since I haven't looked at the code, but used the same for one of my tests), has a problem. It cannot tell the difference between different program windows with the same name and bigger issues arise when trying to deal with a window that changes its name, such as Mushclient does, when you open a new world (its looking at the Title bar for the name, since MS wasn't bright enough to make a "name" field or require that such a filed have a unique name for every program/process.
The safest solution *if* you could manage it, is to do something more complicated, you need to either find the window after creation (poor, but possibly the only solution), then remember that windows ID from then on (or) you would need to run the application with an API call that returns the unique process ID that Windows gives it when it starts, then remember that, so you can find the window when you need it again. Otherwise, the only "safe" solution is to only use it with programs that will not allow you to run more than one copy of themselves at one time, so you can't have a name conflict.
Anyway, nice utility. Its useful, but people should be aware that there are programs that it is "not" reliable to use it with, such as, for example, if you tried to use it with Internet Explorer and had 'several' such windows open. Unless you can identify what window you opened when you ran the program and remember it, you are relying on an API call that has no real idea what you are looking for, so might "find" and "bring to front" the wrong window. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #4 on Thu 21 Sep 2006 02:50 AM (UTC) |
Message
|
Quote:
Is it possible to access the ftp features of Crimson Editor with aliases and a little scripting in mushclient?
Not sure, depends a bit on what scripting is available in Crimson Editor, but I have my doubts. Generally programs are protected from influencing each other, for security reasons. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #5 on Wed 01 Sep 2010 12:36 AM (UTC) |
Message
| These two utilities are now built into MUSHclient version 4.60 onwards as utils.sendtofront and utils.shellexecute (note the different function names, for consistency with the rest of the Lua utilities). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Lasher
USA (22 posts) Bio
|
Date
| Reply #6 on Wed 01 Sep 2010 02:11 AM (UTC) |
Message
| Nice update, but is this a new all-time record in thread necromancy? :)
| Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #7 on Wed 01 Sep 2010 02:53 AM (UTC) |
Message
| Not really, sometimes threads just pop up again after years.
Plus, if someone found this thread and were planning to download the utility, they don't need to bother now. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
37,456 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top