[RESOLVED] Shortcut Key Creator
I don't know if this is possible...
I am creating a program that I want to show when the user types a shortcut on the keyboard. The thing is, I want the user to be able to custom create the shortcut on the form.
As an example, if you right-mouse-click on a shortcut on the desktop and select properties, and select the shortcut tab, you can create a custom key stroke to run that shortcut. I want that textbox on my form.
I have everything working accept for ctrl+shift+E and a few others. For some reason just a handful won't work.
Here is the code I have:
Code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.ControlKey Then
If e.Alt Then
If e.Shift Then
Me.TextBox1.Text = "Ctrl + Alt + Shift + "
Else
Me.TextBox1.Text = "Ctrl + Alt + "
End If
Else
If e.Shift Then
Me.TextBox1.Text = "Ctrl + Shift + "
Else
Me.TextBox1.Text = "Ctrl + "
End If
End If
Exit Sub
ElseIf e.KeyCode = Keys.ShiftKey Then
If e.Control Then
If e.Alt Then
Me.TextBox1.Text = "Ctrl + Alt + Shift + "
Else
Me.TextBox1.Text = "Ctrl + Shift + "
End If
Else
If e.Alt Then
Me.TextBox1.Text = "Alt + Shift + "
End If
End If
Exit Sub
ElseIf e.KeyCode = Keys.Menu Then
If e.Control Then
If e.Shift Then
Me.TextBox1.Text = "Ctrl + Alt + Shift + "
Else
Me.TextBox1.Text = "Ctrl + Alt + "
End If
Else
If e.Shift Then
Me.TextBox1.Text = "Alt + Shift + "
End If
End If
Exit Sub
Else
If e.Control Then
If e.Shift Then
If e.Alt Then
Me.TextBox1.Text = "Ctrl + Alt + Shift + " & UCase(Chr(e.KeyCode))
Else
Me.TextBox1.Text = "Ctrl + Shift + " & UCase(Chr(e.KeyCode))
End If
Else
If e.Alt Then
Me.TextBox1.Text = "Ctrl + Alt + " & UCase(Chr(e.KeyCode))
Else
Me.TextBox1.Text = "Ctrl + " & UCase(Chr(e.KeyCode))
End If
End If
Else
If e.Shift Then
If e.Alt Then
Me.TextBox1.Text = "Alt + Shift + " & UCase(Chr(e.KeyCode))
End If
Else
If e.Alt Then
Me.TextBox1.Text = "Alt + " & UCase(Chr(e.KeyCode))
End If
End If
End If
Exit Sub
End If
End Sub
Re: [RESOLVED] Shortcut Key Creator
Quote:
Do you mean to make a list:
Ctrl + Alt + A
Ctrl + Alt + B
Ctrl + Alt + C
Ctrl + Alt + D
...
Ctrl + Alt + Shift + A
Ctrl + Alt + Shift + B
Ctrl + Alt + Shift + C
Ctrl + Alt + Shift + D
...
Ctrl + Shift + A
Ctrl + Shift + B
Ctrl + Shift + C
Ctrl + Shift + D
...
I'm glad you got it figured out. But, for future reference, no, that wasn't what I was talking about.
I suggested you make one list, A-Z, then allow the user to select which alter keys they wanted to use. Be that Ctrl, Alt, or Shift, or any other key you deemed necessary. Which is quick, easy and simple.
Re: [RESOLVED] Shortcut Key Creator
Ahh... I see. Yeah... I kind of wanted to save space since I will need it. That's not a bad idea. I have seen it in a few other programs, come to think of it. And it would be very easy to do.... Anyhow, thanks for the post!