Tastenkombination abfragen [Gelöst]

Windowsspezifisches Forum , API ,..
Beiträge, die plattformübergreifend sind, gehören ins 'Allgemein'-Forum.
Tompazi
Beiträge: 211
Registriert: 22.09.2007 15:38

Tastenkombination abfragen [Gelöst]

Beitrag von Tompazi »

Titel mag irreführend sein aber mir ist nichts besseres eingefallen.
Ich brauche die Hex werte der Tasten die gerade gedrückt sind. Soweit sogut, mit einer Taste Funktioniert das auch blendend:

Code: Alles auswählen

     Repeat
     For b = 1 To 254
      If b <> 1 And b <> 2 And b <> 4 And b <> 160 And b <> 161 And b <> 162 And b <> 163 And b <> 164 And b <> 165
       If GetAsyncKeyState_(b)
        While GetAsyncKeyState_(b) : Wend
        Debug Hex(b)
       EndIf
      EndIf
     Next b
     Until GetAsyncKeyState_(#VK_ESCAPE)
auch für zwei Tastengleichzeitig funktionierts

Code: Alles auswählen

     For a = 1 To 254
      For b = 1 To 254
       If b <> 1 And b <> 2 And b <> 4 And a <> 1 And a <> 2 And a <> 4 And a <> b And b <> 160 And b <> 161 And b <> 162 And b <> 163 And b <> 164 And b <> 165 And a <> 160 And a <> 161 And a <> 162 And a <> 163 And a <> 164 And a <> 165
        If GetAsyncKeyState_(a) And GetAsyncKeyState_(b)
         While GetAsyncKeyState_(a) And GetAsyncKeyState_(b) : Wend
          Debug Hex(a) + "/" + Hex(b)
        EndIf
       EndIf
      Next b
     Next a
Leider brauche ich das ganze in beiden Versionen gleichzeitig und so funktionierts leider nicht:

Code: Alles auswählen

     For a = 1 To 254
      For b = 1 To 254
       If b <> 1 And b <> 2 And b <> 4 And a <> 1 And a <> 2 And a <> 4 And a <> b And b <> 160 And b <> 161 And b <> 162 And b <> 163 And b <> 164 And b <> 165 And a <> 160 And a <> 161 And a <> 162 And a <> 163 And a <> 164 And a <> 165
        If GetAsyncKeyState_(a) And GetAsyncKeyState_(b)
         While GetAsyncKeyState_(a) And GetAsyncKeyState_(b) : Wend
         Debug Hex(a) + "/" + Hex(b)
        ElseIf GetAsyncKeyState_(a)
         While GetAsyncKeyState_(a) : Wend
         Debug Hex(a)
        EndIf
       EndIf
      Next b
     Next a
MfG Tompazi
Zuletzt geändert von Tompazi am 22.09.2008 17:45, insgesamt 1-mal geändert.
Bild
Benutzeravatar
alter Mann
Beiträge: 201
Registriert: 29.08.2008 09:13
Wohnort: hinterm Mond

Beitrag von alter Mann »

If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down. The least significant bit is not valid in Windows CE, and should be ignored. GetAsyncKeyState returns the current key state even if a window in another thread or process currently has the keyboard focus.

so sollte es gehen

Code: Alles auswählen

      For a = 1 To 254
      For b = 1 To 254
       If b <> 1 And b <> 2 And b <> 4 And a <> 1 And a <> 2 And a <> 4 And a <> b And b <> 160 And b <> 161 And b <> 162 And b <> 163 And b <> 164 And b <> 165 And a <> 160 And a <> 161 And a <> 162 And a <> 163 And a <> 164 And a <> 165
        X = GetAsyncKeyState_(a)
        Y = GetAsyncKeyState_(b)
        If X And Y
         While GetAsyncKeyState_(a) And GetAsyncKeyState_(b) : Wend
         Debug Hex(a) + "/" + Hex(b)
        ElseIf X
         While GetAsyncKeyState_(a) : Wend
         Debug Hex(a)
        EndIf
       EndIf
      Next b
     Next a
Win11 64Bit / PB 6.0
Tompazi
Beiträge: 211
Registriert: 22.09.2007 15:38

Beitrag von Tompazi »

das ist das gleiche in grün aber ich bin jetzt drauf gekommen
so Funktionierts:

Code: Alles auswählen

    Repeat
     For a = 1 To 254
      If a <> 1 And a <> 2 And a <> 4  And a <> 160 And a <> 161 And a <> 162 And a <> 163 And a <> 164 And a <> 165
       If GetAsyncKeyState_(a)
        While GetAsyncKeyState_(a)
         For b = 1 To 254
          If b <> 1 And b <> 2 And b <> 4  And b <> 160 And b <> 161 And b <> 162 And b <> 163 And b <> 164 And b <> 165 And a <> b
           If GetAsyncKeyState_(b)
            vk2.s = Hex(b)
            If Len(vk2) = 1
             vk2 = "0" + vk2
            EndIf
            Continue
           EndIf
          EndIf
         Next b
        Wend
        vk1.s = Hex(a)
        If Len(vk2) = 1
         vk2 = "0" + vk2
        EndIf
        If vk2
         Debug vk1 +"/" + vk2
        Else
         Debug vk1
        EndIf
       EndIf
        vk1 = ""
        vk2 = ""
      EndIf
     Next a
    Until GetAsyncKeyState_(#VK_ESCAPE)
MfG Tompazi
Bild
Antworten