Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Need a little help with a user defined hotkey

Trying to create a part of my program to allow users to keybind whatever button they would like and might be going at it the wrong way. Basically what I have is textbox that will allow the user to enter a number for the hotkey lets say "118" which is F7. I would like it to go like it to replace Keys.F7 to whatever they have.

Code
Select Case e.KeyCode
            Case Keys.F7 // I have tried making this an integer that took a value but //it did not work
                MessageBox.Show("Testing")
            Case Keys.F8
                MessageBox.Show("Testing2")

        End Select
[Image: ZspE9dA.gif]
Two options.

Make a new form that is something like this:
Spoiler (Click to View)

Then use it like:
Code
using (demoForm hkForm = new demoForm())
{
    if(hkForm.ShowDialog() == DialogResult.OK)
    {
        Keys selectedKey = hkForm.SelectedKey;
    }
}

Spoiler (Click to View)

Or use reflection:
Code
Keys k = (Keys)typeof(Keys).GetField(comboBox.Text).GetValue(null);
Lotta blood to let, peace to make, give a fuk about a check
How about a Dictionary(Of Keys, String) to hold it? Prevents you having to account for each key individually with a huge switch.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by uid7683Mar 15, 2019 04:06 PM 1 144 Mar 15, 2019 04:06 PM
Last Post: YouthInAsia
[.NET] by BosskJun 29, 2018 01:16 AM 5 192 Jun 29, 2018 01:16 AM
Last Post: Vyxn
[Python] by DeevezSep 6, 2017 10:46 AM 9 186 Sep 6, 2017 10:46 AM
Last Post: koolkid