vendredi 15 mars 2019

If else with keypress event and notificon c#

I want to write an if else statement that if you press the q button then copy it when you select and that you will get a windows notification when you press q that copy on select in enabled and if you then press q again you then receive a notification that copy on select is disabled. And then it will have to execute this code GetAnswer (Clipboard.GetText (TextDataFormat.UnicodeText));

This is my full code:

    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
        {
            const int WM_DRAWCLIPBOARD = 0x308;
            if (m.Msg == WM_DRAWCLIPBOARD)
            {
                // copy when selecting

                switch (MouseButtons)
                {
                    case MouseButtons.Middle:
                        GetAnswer(Clipboard.GetText(TextDataFormat.UnicodeText));
                        break;
                };
                //copy on ctrl-c or right click copy
                GetAnswer(Clipboard.GetText(TextDataFormat.UnicodeText));
            }
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire