Macro or keyboard mapping

Posted by Somegirl on Tue 23 Nov 2004 09:10 AM — 7 posts, 29,168 views.

#0
Does anyone remember the post that mentioned a third-party substitution for this? I can't find the post anymore.

Also, has anyone used it? How well does it work?

I have been relentlessly advertising Mushclient to IRE games users who currently play their games with the custom Java client that the have on each game's website. One of the common reasons that I'm given that they won't switch is the number of available macros.
Greece #1
Would it be hard to make a customizable menu shortcut key function? For example, any key combination could be assigned to an existing function, like Edit:Copy or whatever, or to a macro. This would merge with the standard macro dialog.
Australia Forum Administrator #2
I've tried to do this a few times in the past with only limited success. As I may have mentioned, the problems are legion:

  • Backwards compatibility (eg. with macros)
  • Different keystrokes for different worlds
  • Some "standard" keystrokes (eg. Alt+F4 to close program) which are not really world-dependant.
  • Modifying the text when you look at menu items (eg. Copy ... Ctrl+C) - what happens to that if you reassign Ctrl+C?
  • A GUI dialog for adding/modifying/deleting keystrokes
  • Need different keystrokes when other windows are open (eg. the notepad)


However after reading your message I think perhaps I have been overthinking the problem. :)

What you really want is a way of having custom keystrokes to do various things, you probably don't really care if the text on a menu is a little out of date.

So, in version 3.53 there is now a facility to do just that. It is done purely in the scripting interface, but I think you will agree it looks pretty simple to use:


  Accelerator ("Ctrl+K", "kill")
  Accelerator ("Ctrl+F", "follow")
  Accelerator ("Ctrl+E", "eat meat")

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

  Accelerator ("Alt+F4", "") -- disable Alt+F4


What this does is let you, per world, reassign any key (or add new keystrokes) by using the fairly simple syntax above.

The text you define for each key is sent to the MUSHclient command processor, so it can be speedwalks, aliases, script commands or whatever you can normally type. The example above shows how you could make Ctrl+M bring up the preferences dialog.

To automate this process, you can define a list of keys you want to assign, and put it into your script file. You would probably put them into the OnWorldOpen function. That is, make a script function called when the world is opened, and put all your keystrokes into that.

Or, put them into a plugin. Whatever works for you.

If you want to share them between worlds, either share the same script file, or "include" the file per world. For example in Lua you might do this:


dofile "mykeystrokes.lua"


There is another new function, AcceleratorList, that lets you query what keys you have assigned. eg. in Lua:


for _, v in pairs (AcceleratorList ()) do print (v) end

-- output:

Ctrl+E = eat meat
Ctrl+F = follow
Ctrl+K = kill
Ctrl+M = /DoCommand 'preferences'
Alt+F4 = 


You could build in extra functionality into a script if you wanted, for example to sort the output, filter on a particular word, and so on.


USA #3
Will you be including a keymapping plugin of somesort?
With the ability to add/list/edit/delete keymaps?

Is it possible to do it in a plugin?
Its just a script that would get executed everytime the world is opened, right? (and on script reload?)
Is Accelerator a MC function? (Nevermind, I read the function list)

Does this trump macros? Or do Macros still work (instead of? or in concert with?)

I guess if its a MC function (first time I read it, I thought it was a LUA function), then its a lot like other clients (tintin) handle their triggers/macros/aliases?

Perhaps it would be a good idea to include a GUI interface? Treat it like aliases/triggers, where its a blank table (as opposed to macros), and then add entries.
I cant imagine it'd be too hard, and would make it more consistant.

Perhaps take OUT the macros then too, since this makes them a bit moot. Or convert the macro dialog to this, or merge them somehow? Then again, you would lose the ability to replace or insert, without some scripting.

Well, I guess I got a bit tangential at the end there.

Edit: Answered my own question about it being a MC function.
Amended on Thu 25 Nov 2004 06:30 AM by Flannel
#4
Nice work Nick! I'll be sending a link to this post out to my friends that have an interest. On the surface it looks great.
Greece #5
By the way, if I reassign Ctrl+Alt+O to nothing, will MC still intercept it and just do nothing, or will it let it pass to the OS? Because I was trying to make a shortcut with a hotkey but the hotkey got captured by MC and did something in it instead of opening the application whose shortcut I had created. It worked when the focus was not on MC.
Australia Forum Administrator #6
Quote:

Will you be including a keymapping plugin of somesort?


Not initially, however one would be easy to write (hint). :)

Quote:

With the ability to add/list/edit/delete keymaps?


The script function lets you add and change them. The AcceleratorList lets you list them. At present I don't plan to have deletions. This is supposed to be something you get right and forget.

Quote:

Is it possible to do it in a plugin?


Yes.

Quote:

Its just a script that would get executed everytime the world is opened, right? (and on script reload?)


Yes.

Quote:

Is Accelerator a MC function? (Nevermind, I read the function list)


Yes.

Quote:

Does this trump macros? Or do Macros still work (instead of? or in concert with?)


Once you have added an accelerator it will override macros and built-in mappings (like Ctrl+F to find). If you don't have an accelerator defined then the macro will still work.

Quote:

I guess if its a MC function (first time I read it, I thought it was a LUA function), then its a lot like other clients (tintin) handle their triggers/macros/aliases?


Yes, I suppose.

Quote:

By the way, if I reassign Ctrl+Alt+O to nothing, will MC still intercept it and just do nothing, or will it let it pass to the OS?


At present it will send nothing. It isn't remembering the original assignment (which is a command number, not a string), so it can't replace it. I suppose it could do that, but not today.