KpyM Telnet/SSH Server - Forum
Keyboard Macros
dc294 Keyboard Macros
 
Again this is a great program.

I am looking to implement keyboard macros in telnet. A simple example might be if the user hits F9 then it does a dir or something. The actual macros would be fairly complex.

I was looking where I might be able to implement this function and I was considering adding a function call in KTelnet::Consume. Have the new function look up the &input to see if it matches a defined macro in a vector and then execute the body of the vector. Does this seem to be a good place to add the new function? Also I have not quite figured out how to send the commands to the current instance of the command shell. Maybe it could be injected directly into the stdin pipe?

Lastly (slightly off topic) I am considering serializing the key map vector for faster loading of client management instance and directly embedding the resulting code. Have you tried this in the past? I have seen several techniques to get around the string pointer issues if this has been the problem.

Thanks.


Kroum Grigorov
 
Sorry for the late reply, but I'm under huge pressure at work right now and have very little time to look after KpyM Server.

Now on your question:

> Lastly (slightly off topic) I am considering serializing the key map vector... Have you tried this in the past?
No I have not used serialization in KpyM project for the reason that I want to have all params in ini files. This is because ini files are more readable and easier to edit than serialized data. I don't think you will have any issues using serialization if you choose to use it.

>Also I have not quite figured out how to send the commands to the current instance...Maybe it could be injected directly into the stdin pipe?
The easier is to use the KKey::Consume( std::string & input )
This will "generate" the first key passed in the input buffer and remove it from the buffer.
The keys in the input buffer should be "encoded" the same way a telnet client does. This menas that most of the characters will be the same (a-zA-Z0-9...) except for the function keys that are encoded using more than one character.

>I am looking to implement keyboard macros in telnet.
I think you can do this:
1) define a [Macro] section in the ini file with the keys

input1 = "0E"
macro1 = "FF 0E 11 ..."
input2 = "0E"
macro2 = "FF 0E 11 ..."
...

The input# parameter will hold the key that triggers the macro, these are the same values as in utf-8.ini/[KKey] (ex: F9 is "1B 4F 58" you can look this up in utf-8.ini)

The macro# parameter will hold the keys that the macro is composed of, these are also the values from utf-8.ini( ex: to make the macro generate the keys "test + F9" you will have "74 65 73 74 1B 4F 58")

2) You will have to write some code that read this macro section and load the input#/macro# pairs

3) Write a function KMacro::Consume( std::string & input )
that reads the first "key" from the input parameter and if this is a "registered" macro input then call KKey::Consume for this macro values and removes the "processed" key from the input.

4) Place the line
if( Macro::Consume( input ) ) continue;
just before the line
if( this->key->Consume( input ) ) continue;
in KSession.hxx file

In short:
You will load predefined macro pairs the holding the pressed key value that trigers the macro and the keys that should be pressed when the macro is triggered. Then you use a piece of code that waits for a macro key to come and it calls the KKey::Consume on the macro value. The KKey::Consume should then generate all the keys that the macro triggers

Kroum


dc294 Thanks
 
Thank you.


 

© 2007 - 2008 Kroum Grigorov
Powered by phpBB © 2001, 2005 phpBB Group