Tastenkombination , Getasynckeystate , GetKeystate.

  • VB.NET

Es gibt 4 Antworten in diesem Thema. Der letzte Beitrag () ist von AsdAsd1337.

    Tastenkombination , Getasynckeystate , GetKeystate.

    Hallo,

    Ich habe hier einen Code mit dem ich @ nach der Tastenkombination für @ (Alt Gr + Q) ausgeben will.

    Habe folgenden Code:


    VB.NET-Quellcode

    1. Public Class Form1
    2. Dim result As Integer
    3. Private Declare Function GetAsyncKeyState Lib "USER32" (ByVal vKey As Long) As Integer
    4. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5. Timer1.Start()
    6. End Sub
    7. Public Function GetShift() As Boolean
    8. GetShift = CBool(GetAsyncKeyState(&H10))
    9. End Function
    10. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    11. For i As Integer = 1 To 225
    12. result = 0
    13. result = GetAsyncKeyState(i)
    14. If result = -32767 Then
    15. If GetShift() = False Then
    16. Select Case (i)
    17. Case 164 + 81
    18. TextBox1.Text = "@"
    19. End Select
    20. End If
    21. End If
    22. Next i
    23. End Sub
    24. End Class


    Funktioniert leider nicht


    Weiss jemand die Lösung?



    Mfg Kevin.

    VB.NET-Quellcode

    1. Public Class Form1
    2. 'Enum für die Tasten, hab jetzt nur die beiden eingetragen, falls du alle tastencodes haben willst, dann wirf mal google an.
    3. Public Enum Keys As Integer
    4. AltGR = &HA5
    5. Q = &H51
    6. End Enum
    7. Public Enum Status As Integer
    8. Gedrückt = &H8000 'ist momentan gedrückt
    9. WarGedrückt = &H1 'taste wurde seit dem letzten check gedrückt
    10. End Enum
    11. Private Declare Function GetAsyncKeyState Lib "USER32" (ByVal vKey As Long) As Integer
    12. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    13. Timer1.Enabled = True
    14. End Sub
    15. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    16. If (GetAsyncKeyState(Keys.AltGR) And Status.Gedrückt) Then 'Alt Gr ist gedrückt
    17. If (GetAsyncKeyState(Keys.Q) And Status.Gedrückt) Then 'Q ist gedrückt
    18. Me.TextBox1.SelectedText = "@"
    19. End If
    20. End If
    21. End Sub
    22. End Class
    Hallo,

    Ich habe auch so ein Problem.

    Und zwar möchte ich die Tastenkombination Strg + Links Alt abfragen, kann mir jemand helfen?

    E: Hat sich erledigt , ich habs.

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „AsdAsd1337“ ()