0

I had been asked to create winform application where there are two comboboxes.
The first box contains options like Ctrl+Alt, Ctrl+Shift and Alt+Shift. The second box contains alphabets from a-z and numbers 0-9..
The form also contains a button called "Register". My task is that, when I click the register button, the options selected in the combo boxes must be considered as the hotkey and it should be registered. Kindly help me with the code, as I am new to this technology.

private void button1_Click(object sender, EventArgs e)
{
    if (comboBox1.SelectedItem.ToString() != str && comboBox3.SelectedItem.ToString() != s)
    {
        str = comboBox1.SelectedItem.ToString();
        byte str1 = (byte)(str)[0];
        s = comboBox3.SelectedItem.ToString();
        byte s1 = (byte)(s)[0];
        RegisterHotKey(this.Handle, this.GetType().GetHashCode(), Win32Modifiers, s1);
    }
    base.WndProc(ref msg);
}

protected override void WndProc(ref Message m)
{
    if(m.Msg ==  )
    base.WndProc(ref m);
}

This is what I had did so far

csharpbd
  • 3,786
  • 4
  • 23
  • 32
Deepika
  • 1
  • 2
  • 2
    Possible duplicate of [Best way to implement keyboard shortcuts in a Windows Forms application?](http://stackoverflow.com/questions/400113/best-way-to-implement-keyboard-shortcuts-in-a-windows-forms-application) – C. Helling Mar 08 '17 at 08:57
  • 1
    kindly, give a starting point, your progress and the point where you run into difficulties. Up to now the problem description is too broad. People will not write the entire code here for you – Mong Zhu Mar 08 '17 at 08:57
  • Should these hotkeys registered only to your application or are they global hotkeys? – Stephan Bauer Mar 08 '17 at 09:02
  • Yes.. It should be used only in my application.. I had registered the keys but I dont know how to pass it as a Wndproc message.. – Deepika Mar 09 '17 at 04:13

1 Answers1

0

I would go about this by just simulating the keys selected being pressed. like how and auto-typer would. C# Simulate Key Press check this out and see if you could figure it out from there. good luck.

Community
  • 1
  • 1
Valhalla
  • 1
  • 3