vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Brandneu! sevEingabe v3.0 - Das Eingabecontrol der Superlative!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   RSS-Feeds  | Newsletter  | Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2019
 
zurück
Rubrik: Maus & Tastatur22.03.05
GetAsyncKeyState-Funktion

Diese Funktion ermittelt, ob seit ihrem letzten Aufruf eine bestimmte Tasteneingabe erfolgt ist.

Betriebssystem:  Win95, Win98, WinNT 3.1, Win2000, WinMEViews:  39.366 

Deklaration:

 Declare  Function  GetAsyncKeyState  Lib  "user32.dll"  ( ByVal vKey As Long ) As Long

Beschreibung:
Diese Funktion ermittelt, ob seit ihrem letzten Aufruf eine bestimmte Tasteneingabe erfolgt ist.

Parameter:
vKeyErwartet eine der Tastaturkonstanten die auf einen schon betätigten Tastendruck hin überprüft werden soll.

vKey Konstanten:

Const VK_LBUTTON = &H1
' Linker Mausbutton
 
Const VK_RBUTTON = &H2
' Rechter Mausbutton
 
Const VK_MBUTTON = &H4
' Mittlerer Mausbutton
 
Const VK_BACK = &H8
' Backspace Taste
 
Const VK_TAB = &H9
' Tab Taste
 
Const VK_CLEAR = &HC
' Numpad 5 ohne Numlock
 
Const VK_RETURN = &HD
' Enter Taste
 
Const VK_SHIFT = &H10
' Shift Taste
 
Const VK_CONTROL = &H11
' STRG Taste
 
Const VK_MENU = &H12
' Alt Taste
 
Const VK_PAUSE = &H13
' Pause/Untbr
 
Const VK_CAPITAL = &H14
' Caps Lock/Feststelltaste
 
Const VK_ESCAPE = &H1B
' Escape
 
Const VK_SPACE = &H20
' Space/Leertaste
 
Const VK_PRIOR = &H21
' PageUp/Bild hoch
 
Const VK_NEXT = &H22
' PageDown/Bild runter
 
Const VK_END = &H23
' Ende
 
Const VK_HOME = &H24
' Home/Pos1
 
Const VK_LEFT = &H25
' Linke Pfeiltaste
 
Const VK_UP = &H26
' Obere Pfeiltaste
 
Const VK_RIGHT = &H27
' Rechte Pfeiltaste
 
Const VK_DOWN = &H28
' Untere Pfeiltaste
 
Const VK_PRINT = &H2A
' Drucken (Nokia Tastaturen)
 
Const VK_SNAPSHOT = &H2C
' Drucken/S-Abf
 
Const VK_INSERT = &H2D
' Einfügen
 
Const VK_DELETE = &H2E
' Entfernen
 
Const VK_HELP = &H2F
' Hilfe
 
Const VK_0 = &H30
' Taste 0
 
Const VK_1 = &H31
' Taste 1
 
Const VK_2 = &H32
' Taste 2
 
Const VK_3 = &H33
' Taste 3
 
Const VK_4 = &H34
' Taste 4
 
Const VK_5 = &H35
' Taste 5
 
Const VK_6 = &H36
' Taste 6
 
Const VK_7 = &H37
' Taste 7
 
Const VK_8 = &H38
' Taste 8
 
Const VK_9 = &H39
' Taste 9
 
Const VK_A = &H41
' Taste A
 
Const VK_B = &H42
' Taste B
 
Const VK_C = &H43
' Taste C
 
Const VK_D = &H44
' Taste D
 
Const VK_E = &H45
' Taste E
 
Const VK_F = &H46
' Taste F
 
Const VK_G = &H47
' Taste G
 
Const VK_H = &H48
' Taste H
 
Const VK_I = &H49
' Taste I
 
Const VK_J = &H4A
' Taste J
 
Const VK_K = &H4B
' Taste K
 
Const VK_L = &H4C
' Taste L
 
Const VK_M = &H4D
' Taste M
 
Const VK_N = &H4E
' Taste N
 
Const VK_O = &H4F
' Taste O
 
Const VK_P = &H50
' Taste P
 
Const VK_Q = &H51
' Taste Q
 
Const VK_R = &H52
' Taste R
 
Const VK_S = &H53
' Taste S
 
Const VK_T = &H54
' Taste T
 
Const VK_U = &H55
' Taste U
 
Const VK_V = &H56
' Taste V
 
Const VK_W = &H57
' Taste W
 
Const VK_X = &H58
' Taste X
 
Const VK_Y = &H59
' Taste Y
 
Const VK_Z = &H5A
' Taste Z
 
Const VK_STARTKEY = &H5B
' Startmenütaste
 
Const VK_CONTEXTKEY = &H5D
' Kontextmenü
 
Const VK_NUMPAD0 = &H60
' Numpad Taste 0
 
Const VK_NUMPAD1 = &H61
' Numpad Taste 1
 
Const VK_NUMPAD2 = &H62
' Numpad Taste 2
 
Const VK_NUMPAD3 = &H63
' Numpad Taste 3
 
Const VK_NUMPAD4 = &H64
' Numpad Taste 4
 
Const VK_NUMPAD5 = &H65
' Numpad Taste 5
 
Const VK_NUMPAD6 = &H66
' Numpad Taste 6
 
Const VK_NUMPAD7 = &H67
' Numpad Taste 7
 
Const VK_NUMPAD8 = &H68
' Numpad Taste 8
 
Const VK_NUMPAD9 = &H69
' Numpad Taste 9
 
Const VK_MULTIPLY = &H6A
' Numpad Multiplikations Taste (*)
 
Const VK_ADD = &H6B
' Numpad Additions Taste (+)
 
Const VK_SUBTRACT = &H6D
' Numpad Subtrations Taste (-)
 
Const VK_DECIMAL = &H6E
' Numpad Komma Taste (,)
 
Const VK_DIVIDE = &H6F
' Numpad Dividierungs Taste (/)
 
Const VK_F1 = &H70
' F1 Taste
 
Const VK_F2 = &H71
' F2 Taste
 
Const VK_F3 = &H72
' F3 Taste
 
Const VK_F4 = &H73
' F4 Taste
 
Const VK_F5 = &H74
' F5 Taste
 
Const VK_F6 = &H75
' F6 Taste
 
Const VK_F7 = &H76
' F7 Taste
 
Const VK_F8 = &H77
' F8 Taste
 
Const VK_F9 = &H78
' F9 Taste
 
Const VK_F10 = &H79
' F10 Taste
 
Const VK_F11 = &H7A
' F11 Taste
 
Const VK_F12 = &H7B
' F12 Taste
 
Const VK_F13 = &H7C
' F13 Taste
 
Const VK_F14 = &H7D
' F14 Taste
 
Const VK_F15 = &H7E
' F15 Taste
 
Const VK_F16 = &H7F
' F16 Taste
 
Const VK_F17 = &H80
' F17 Taste
 
Const VK_F18 = &H81
' F18 Taste
 
Const VK_F19 = &H82
' F19 Taste
 
Const VK_F20 = &H83
' F20 Taste
 
Const VK_F21 = &H84
' F21 Taste
 
Const VK_F22 = &H85
' F22 Taste
 
Const VK_F23 = &H86
' F23 Taste
 
Const VK_F24 = &H87
' F24 Taste
 
Const VK_NUMLOCK = &H90
' Numlock Taste
 
Const VK_OEM_SCROLL = &H91
' Scroll Lock
 
Const VK_LSHIFT = &HA0
' Linke Shift-Taste
 
Const VK_RSHIFT = &HA1
' Rechte Shift-Taste
 
Const VK_LCONTROL = &HA2
' Linke STRG-Taste
 
Const VK_RCONTROL = &HA3
' Rechte STRG-Taste
 
Const VK_LMENU = &HA4
' Linke ALT-Taste
 
Const VK_RMENU = &HA5
' Rechte ALT-Taste
 
Const VK_OEM_1 = &HBA
' ";"-Taste
 
Const VK_OEM_PLUS = &HBB
' "
 
Const VK_OEM_COMMA = &HBC
' ","-Taste
 
Const VK_OEM_MINUS = &HBD
' "-"-Taste
 
Const VK_OEM_PERIOD = &HBE
' "."-taste
 
Const VK_OEM_2 = &HBF
' "/"-Taste
 
Const VK_OEM_3 = &HC0
' "`"-Taste
 
Const VK_OEM_4 = &HDB
' "["-Taste
 
Const VK_OEM_5 = &HDC
' "\"-Taste
 
Const VK_OEM_6 = &HDD
' "]"-Taste
 
Const VK_OEM_7 = &HDE
' "
 
Const VK_ICO_F17 = &HE0
' F17 einer Olivetti Tastatur (Intern)
 
Const VK_ICO_F18 = &HE1
' F18 einer Olivetti Tastatur (Intern)
 
Const VK_OEM102 = &HE2
' "<"-Taste oder "|"-Taste einer IBM-Kompatiblen 102 Tastatur (Nicht US)
 
Const VK_ICO_HELP = &HE3
' Hilfetaste einer Olivetti Tastatur (Intern)
 
Const VK_ICO_00 = &HE4
' 00-Taste einer Olivetti Tastatur (Intern)
 
Const VK_ICO_CLEAR = &HE6
' Löschen Taste einer Olivetti Tastatur (Intern)
 
Const VK_OEM_RESET = &HE9
' Reset Taste (Nokia)
 
Const VK_OEM_JUMP = &HEA
' Springen Taste (Nokia)
 
Const VK_OEM_PA1 = &HEB
' PA1 Taste (Nokia)
 
Const VK_OEM_PA2 = &HEC
' PA2 Taste (Nokia)
 
Const VK_OEM_PA3 = &HED
' PA3 Taste (Nokia)
 
Const VK_OEM_WSCTRL = &HEE
' WSCTRL Taste (Nokia)
 
Const VK_OEM_CUSEL = &HEF
' WSCTRL Taste (Nokia)
 
Const VK_OEM_ATTN = &HF0
' ATTN Taste (Nokia)
 
Const VK_OEM_FINNISH = &HF1
' Fertig Taste (Nokia)
 
Const VK_OEM_COPY = &HF2
' Kopieren Taste (Nokia)
 
Const VK_OEM_AUTO = &HF3
' Auto Taste (Nokia)
 
Const VK_OEM_ENLW = &HF4
' ENLW Taste (Nokia)
 
Const VK_OEM_BACKTAB = &HF5
' BackTab Taste (Nokia)
 
Const VK_ATTN = &HF6
' ATTN-Taste
 
Const VK_CRSEL = &HF7
' CRSEL-Taste
 
Const VK_EXSEL = &HF8
' EXSEL-Taste
 
Const VK_EREOF = &HF9
' EREOF-Taste
 
Const VK_PLAY = &HFA
' PLAY-Taste
 
Const VK_ZOOM = &HFB
' ZOOM-Taste
 
Const VK_NONAME = &HFC
' NONAME-Taste
 
Const VK_PA1 = &HFD
' PA1-Taste
 
Const VK_OEM_CLEAR = &HFE
' OEM_CLEAR-Taste

Rückgabewert:
Ist die Funktion erfolgreich und die angegeben Taste gedrückt, so wird das Bit "&H8000" in der Rückgabe gesetzt. Ist die Taste momentan nicht gedrückt, wurde aber seit dem letzten Funktionsaufruf betätigt, so ist in der Rückgabe das "&H1" Bit gesetzt. Wurde und ist die Taste nicht gedrückt worden oder trat ein Fehler bei dem Funktionsaufruf auf so ist derWert "0" die Rückgabe.

Beispiel:

Private Declare Function GetAsyncKeyState Lib "user32.dll" ( _
  ByVal vKey As Long) As Long
 
' GetAsyncKeyState vKey-Konstanten
Private Const VK_LBUTTON = &H1  ' Linker Mausbutton
Private Const VK_RBUTTON = &H2  ' Rechter Mausbutton
Private Const VK_MBUTTON = &H4  ' Mittlerer Mausbutton
Private Const VK_BACK = &H8  ' Backspace Taste
Private Const VK_TAB = &H9  ' Tab Taste
Private Const VK_CLEAR = &HC  ' Numpad 5 ohne Numlock
Private Const VK_RETURN = &HD  ' Enter Taste
Private Const VK_SHIFT = &H10  ' Shift Taste
Private Const VK_CONTROL = &H11  ' STRG Taste
Private Const VK_MENU = &H12  ' Alt Taste
Private Const VK_PAUSE = &H13  ' Pause/Untbr
Private Const VK_CAPITAL = &H14  ' Caps Lock/Feststelltaste
Private Const VK_ESCAPE = &H1B  ' Escape
Private Const VK_SPACE = &H20  ' Space/Leertaste
Private Const VK_PRIOR = &H21  ' PageUp/Bild hoch
Private Const VK_NEXT = &H22  ' PageDown/Bild runter
Private Const VK_END = &H23  ' Ende
Private Const VK_HOME = &H24  ' Home/Pos1
Private Const VK_LEFT = &H25  ' Linke Pfeiltaste
Private Const VK_UP = &H26  ' Obere Pfeiltaste
Private Const VK_RIGHT = &H27  ' Rechte Pfeiltaste
Private Const VK_DOWN = &H28 ' Untere Pfeiltaste
Private Const VK_PRINT = &H2A  ' Drucken (Nokia Tastaturen)
Private Const VK_SNAPSHOT = &H2C  ' Drucken/S-Abf
Private Const VK_INSERT = &H2D  ' Einfügen
Private Const VK_DELETE = &H2E  ' Entfernen
Private Const VK_HELP = &H2F  ' Hilfe
Private Const VK_0 = &H30  ' Taste 0
Private Const VK_1 = &H31  ' Taste 1
Private Const VK_2 = &H32  ' Taste 2
Private Const VK_3 = &H33   ' Taste 3
Private Const VK_4 = &H34  ' Taste 4
Private Const VK_5 = &H35  ' Taste 5
Private Const VK_6 = &H36  ' Taste 6
Private Const VK_7 = &H37  ' Taste 7
Private Const VK_8 = &H38   ' Taste 8
Private Const VK_9 = &H39   ' Taste 9
Private Const VK_A = &H41   ' Taste A
Private Const VK_B = &H42   ' Taste B
Private Const VK_C = &H43   ' Taste C
Private Const VK_D = &H44   ' Taste D
Private Const VK_E = &H45   ' Taste E
Private Const VK_F = &H46   ' Taste F
Private Const VK_G = &H47   ' Taste G
Private Const VK_H = &H48  ' Taste H
Private Const VK_I = &H49  ' Taste I
Private Const VK_J = &H4A  ' Taste J
Private Const VK_K = &H4B  ' Taste K
Private Const VK_L = &H4C   ' Taste L
Private Const VK_M = &H4D   ' Taste M
Private Const VK_N = &H4E  ' Taste N
Private Const VK_O = &H4F  ' Taste O
Private Const VK_P = &H50   ' Taste P
Private Const VK_Q = &H51   ' Taste Q
Private Const VK_R = &H52 ' Taste R
Private Const VK_S = &H53  ' Taste S
Private Const VK_T = &H54   ' Taste T
Private Const VK_U = &H55  ' Taste U
Private Const VK_V = &H56  ' Taste V
Private Const VK_W = &H57   ' Taste W
Private Const VK_X = &H58  ' Taste X
Private Const VK_Y = &H59  ' Taste Y
Private Const VK_Z = &H5A  ' Taste Z
Private Const VK_STARTKEY = &H5B   ' Startmenütaste
Private Const VK_CONTEXTKEY = &H5D  ' Kentextmenü
Private Const VK_NUMPAD0 = &H60  ' Numpad Taste 0
Private Const VK_NUMPAD1 = &H61  ' Numpad Taste 1
Private Const VK_NUMPAD2 = &H62  ' Numpad Taste 2
Private Const VK_NUMPAD3 = &H63  ' Numpad Taste 3
Private Const VK_NUMPAD4 = &H64  ' Numpad Taste 4
Private Const VK_NUMPAD5 = &H65 ' Numpad Taste 5
Private Const VK_NUMPAD6 = &H66  ' Numpad Taste 6
Private Const VK_NUMPAD7 = &H67  ' Numpad Taste 7
Private Const VK_NUMPAD8 = &H68   ' Numpad Taste 8
Private Const VK_NUMPAD9 = &H69   ' Numpad Taste 9
Private Const VK_MULTIPLY = &H6A ' Numpad Multiplikations Taste (*)
Private Const VK_ADD = &H6B  ' Numpad Additions Taste (+)
Private Const VK_SUBTRACT = &H6D   ' Numpad Subtrations Taste (-)
Private Const VK_DECIMAL = &H6E   ' Numpad Komma Taste (,)
Private Const VK_DIVIDE = &H6F ' Numpad Devidierungs Taste (/)
Private Const VK_F1 = &H70  ' F1 Taste
Private Const VK_F2 = &H71  ' F2 Taste
Private Const VK_F3 = &H72   ' F3 Taste
Private Const VK_F4 = &H73   ' F4 Taste
Private Const VK_F5 = &H74   ' F5 Taste
Private Const VK_F6 = &H75   ' F6 Taste
Private Const VK_F7 = &H76  ' F7 Taste
Private Const VK_F8 = &H77  ' F8 Taste
Private Const VK_F9 = &H78   ' F9 Taste
Private Const VK_F10 = &H79  ' F10 Taste
Private Const VK_F11 = &H7A   ' F11 Taste
Private Const VK_F12 = &H7B   ' F12 Taste
Private Const VK_F13 = &H7C  ' F13 Taste
Private Const VK_F14 = &H7D  ' F14 Taste
Private Const VK_F15 = &H7E   ' F15 Taste
Private Const VK_F16 = &H7F   ' F16 Taste
Private Const VK_F17 = &H80   ' F17 Taste
Private Const VK_F18 = &H81   ' F18 Taste
Private Const VK_F19 = &H82   ' F19 Taste
Private Const VK_F20 = &H83   ' F20 Taste
Private Const VK_F21 = &H84   ' F21 Taste
Private Const VK_F22 = &H85   ' F22 Taste
Private Const VK_F23 = &H86   ' F23 Taste
Private Const VK_F24 = &H87   ' F24 Taste
Private Const VK_NUMLOCK = &H90  ' Numlock Taste
Private Const VK_OEM_SCROLL = &H91  ' Scroll Lock
Private Const VK_LSHIFT = &HA0 ' Linke Shift-Taste
Private Const VK_RSHIFT = &HA1  ' Rechte Shift-Taste
Private Const VK_LCONTROL = &HA2  ' Linke STRG-Taste
Private Const VK_RCONTROL = &HA3 ' Rechte STRG-Taste
Private Const VK_LMENU = &HA4  ' Linke ALT-Taste
Private Const VK_RMENU = &HA5  ' Rechte ALT-Taste
Private Const VK_OEM_1 = &HBA  ' ";"-Taste
Private Const VK_OEM_PLUS = &HBB   ' "
Private Const VK_OEM_COMMA = &HBC   ' ","-Taste
Private Const VK_OEM_MINUS = &HBD   ' "-"-Taste
Private Const VK_OEM_PERIOD = &HBE   ' "."-taste
Private Const VK_OEM_2 = &HBF   ' "/"-Taste
Private Const VK_OEM_3 = &HC0   ' "`"-Taste
Private Const VK_OEM_4 = &HDB   ' "["-Taste
Private Const VK_OEM_5 = &HDC   ' "\"-Taste
Private Const VK_OEM_6 = &HDD   ' "]"-Taste
Private Const VK_OEM_7 = &HDE   ' "
Private Const VK_ICO_F17 = &HE0   ' F17 einer Olivette Tastatur (Intern)
Private Const VK_ICO_F18 = &HE1   ' F18 einer Olivette Tastatur (Intern)
Private Const VK_OEM102 = &HE2   ' "<"-Taste oder "|"-Taste einer  
 ' IBM-Kompatiblen 102 Tastatur (Nicht US)
Private Const VK_ICO_HELP = &HE3   ' Hilfetaste einer Olivetti Tastatur (Intern) 
Private Const VK_ICO_00 = &HE4  ' 00-Taste einer Olivetti Tastatur (Intern)
Private Const VK_ICO_CLEAR = &HE6   ' Löschen Taste einer Olivetti Tastatur (Intern) 
Private Const VK_OEM_RESET = &HE9  ' Reset Taste (Nokia)
Private Const VK_OEM_JUMP = &HEA   ' Springen Taste (Nokia)
Private Const VK_OEM_PA1 = &HEB   ' PA1 Taste (Nokia)
Private Const VK_OEM_PA2 = &HEC  ' PA2 Taste (Nokia)
Private Const VK_OEM_PA3 = &HED  ' PA3 Taste (Nokia)
Private Const VK_OEM_WSCTRL = &HEE   ' WSCTRL Taste (Nokia)
Private Const VK_OEM_CUSEL = &HEF   ' WSCTRL Taste (Nokia)
Private Const VK_OEM_ATTN = &HF0   ' ATTN Taste (Nokia)
Private Const VK_OEM_FINNISH = &HF1  ' Fertig Taste (Nokia)
Private Const VK_OEM_COPY = &HF2   ' Kopieren Taste (Nokia)
Private Const VK_OEM_AUTO = &HF3   ' Auto Taste (Nokia)
Private Const VK_OEM_ENLW = &HF4   ' ENLW Taste (Nokia)
Private Const VK_OEM_BACKTAB = &HF5   ' BackTab Taste (Nokia)
Private Const VK_ATTN = &HF6   ' ATTN-Taste
Private Const VK_CRSEL = &HF7   ' CRSEL-Taste
Private Const VK_EXSEL = &HF8   ' EXSEL-Taste
Private Const VK_EREOF = &HF9   ' EREOF-Taste
Private Const VK_PLAY = &HFA  ' PLAY-Taste
Private Const VK_ZOOM = &HFB   ' ZOOM-Taste
Private Const VK_NONAME = &HFC   ' NONAME-Taste
Private Const VK_PA1 = &HFD   ' PA1-Taste
Private Const VK_OEM_CLEAR = &HFE  ' OEM_CLEAR-Taste
' Überprüfen ob eine Taste gedrückt wurde
Private Sub Command1_Click()
  Dim Retval As Long
 
  ' Überprüfen ob seit dem letzten Funktionsaufruf die Taste X gedrückt wurde
  Retval = GetAsyncKeyState(VK_X)
 
  ' Auswerten des Ergebnisses
  If CBool(Retval And &H8000) Then
    MsgBox "Die Taste ""X"" ist momentan gedrückt."
 
  ElseIf CBool(Retval And &H1) Then
    MsgBox "Die Taste ""X"" wurde seit dem letztem Check gedrückt."
 
  Else
    MsgBox "Die Taste ""X"" wurde seit der letzten Überprüfung nicht gedrückt." 
  End If
End Sub

Diese Seite wurde bereits 39.366 mal aufgerufen.

nach obenzurück
 
   

Druckansicht Druckansicht Copyright ©2000-2019 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel