[VB] Necesito ayuda con Hoykeys

(1/1)

avmiitxe:
Hola, estoy haciendo un programa en Visual Basic 2008, que al darle a la tecla F2 por ejemplo se activa el Timer1, aquí os voy a dejar un poco de código para explicar mejor:

Timer1:
Código:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      
        CheckBox1.checked = true

    End Sub

Timer2:
Código:

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Dim hotkey As Boolean

        If TextBox1.Text = "F1" Then
            hotkey = GetAsyncKeyState(Keys.F1)
        End If

        If TextBox1.Text = "F2" Then
            hotkey = GetAsyncKeyState(Keys.F2)
        End If

        If hotkey = True Then
            Timer1.Start()
        End If


    End Sub

Quiero hacer que el Timer1 se active al darle A LA TECLA QUE HAY ESCRITA EN EL TEXTBOX1, y quiero hacer que se puedan poner todas las teclas del teclado, pero sería una matada poner todas las teclas con
Código:

If TextBox1.Text = "F3" Then
            hotkey = GetAsyncKeyState(Keys.F3)
        End If

Y así seguir F4, F5, F6...

¿Hay alguna manera de que la tecla que introduzca en el Textbox1 sea la hotkey sin tener que escribir todas?

Por ejemplo:
Código:

           hotkey = GetAsyncKeyState(Textbox1.text)
        End If

pero eso no funciona, ¿es posible hacer lo que quiero?

gracias de antebrazo

CAR3S?:
esto no es .net?

79137913:
HOLA!!!

Esto va en Net

Reportado

GRACIAS POR LEER!!!

Navegación

[0] Índice de Mensajes