tags:

views:

116

answers:

3

Hello, I wan't to create a c# application which simplifies the life of a writer by using macros. I know this tool already exists in well-known programs such as Word or OpenOffice. However, I want to add this extra 'tool' (the macro program) to a main program I've already done.

So, what this program should do is replace keybindings for sentences (i.e. !DP into Deer Parents,.. or Ctrl+L into Looking forward to..).

These are the characteristics the program should have: 1- Windows form with a textarea to write in it. (here is where the user types his/her text and applies the macros) 2- A window with the macroing options (a textarea where the user types the sentence to be replaced and a textbox where the keybinding comes in) and obviously an apply button. 3- A 'copy-to-clipboard' button where the user copies everything written in the textarea (from characteristic number 1).

I hope I explained myself loud and clear. To make it short, I just need a c# program to write in, where the user can choose and then apply macros to finally copy it onto i.e. Gmail, hotmail, etc..

Thanks you very, very much in advance. Any extra info you'll need please let me know. And, by the way, I don't want someone to code this FOR me, but guide me and give me some hints .. Thank you! Chris.

A: 

I feel like you're asking too much in one question. It's not clear which of the pieces above your're having trouble with.

Overall, mentally map out a sequence of implementation and do it piece by piece, not worrying too much about future pieces. [I'm kind of pre-supposing that they are self-evidenetly somewhat independent.]

For example I would not start with the macro capture window. Instead I'd probably go for detecting macro activation in the main window. How do you know that the user has hit a valid macro invocation ... hmm maybe i need a "is this a macro" method ...

You get that going withoiut solving anything else. Or attack cut and paste. Attack one problem at a time - at least as far as taking it to the "i need a method for ...".

djna
A: 

Hello, yes you're right. I did not create a mind-map of this app. first.

Program Layout: Windows form (Textbox, copy button, exit button) Top-bar (File>Exit ; Options>Macros) Macros-window (Keybinding, Replace-sentence, apply button)

These are the 'if' values and the program responses in case of an error: Keybindings will be 'pre'-made. Meaning, user won't be able to choose between the key-button, only the letter. (i.e. 'Ctrl' will be obligatory and the letter which creates the keybinding for the macro will be chosen by user. Ctrl is just an example.)

The keybinding textbox will only allow user to type a maximum of 3 characters.

IMAGE: http://i27.tinypic.com/mm9276.jpg

The replace-sentence texboxes have a very high limit of characters, allowing user to replace long sentences.

I hope gives a better idea of what I'm looking forward to. Thanks for reading my message! Chris.

cr0z3r
What you're describing sounds boith useful and implementable. It's not clear to me what help you are actually asking for. You sound as though you have an idea of what you want to build and more or less how to do it. Without more specific questions it's hard to see how we could help.
djna
A: 

Okay, the kind of help I need is guideness. I'm not very familiar with C# (I know how to code and stuff, but create new dictionaries and, for example in this case, macros isn't my thing).

I can create the windows form, add the textboxes, it's basic functions as well as with the buttons. What I need help with, is establish the 'engine' which will allow users to add their own macros and make them work.

I recieved some help from a friend, but sadly I don't really know how to implement the following code and where to start with it.

What I recieved: ------ starts here ------

The following method added to a form will detect the arrow keys being pressed....

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        switch (keyData)
        {
            case Keys.Up:
                break;
            case Keys.Down:
                break;
            case Keys.Right:
                break;
            case Keys.Left:
                break;
            case Keys.Control:  // detect CTRL key being pressed.
                break;
            default:
                break;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }

You would need to detect multiple keystrokes for macro sequences. Sounds like it might be a good job for the State Pattern.

interface IMacro
{
     void InsertText();
}

Create a Dictionary of State objects and retrieve them using the keysequence as a TKey. If the TKey is not found, then no object is retrieved and nothing happens to the key stroke. If the TKey is found, then call a method that replaces the current word being typed with the macro. That interface definition might need some work, but I hope you get the idea.

------ ends here ------

cr0z3r
You have several questions here - and I don't know C# well enough to answer them (I do Java) You may need to post each one separately. Some things such as Dictionaries are actually quite easy. I recommend that you google for C sharp and Dictionaries and hence find and try some code examples. Then, if ncessary you can ask a more specific question about how to apply dictionaries to this problem. You learn far more this way. Good luck.
djna