Code-Beispiel
Tastatur Systemweit abfragen.
Lizenz: | Erster Autor: | Letzte Bearbeitung: |
k. A. | Eternal_Pain | 13.06.2007 |
Quelle:fb@rchive
Autor:Benjamin Kunz
So, heute Zeig ich euch mal, wie ihr trotz inaktivem Programmfenster
in euer Anwendung immer noch die Tastatur abfragen könnt
Dim Shared sTaste As String
Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState"_
(ByVal vKey As Long) As Integer
Function CompKey(KCode As Long, KText As String) As Integer
Dim Result As Integer
Result = GetAsyncKeyState(KCode)
If Result = -32767 Then
Print "[" & KText & "]"
sTaste = KText
CompKey = 1
Else
CompKey = 0
End If
End Function
Sub ab ()
Dim X As Long
For X = 48 To 90
If CompKey(X, UCase(Chr$(X))) Then Exit Sub
If CompKey(X + 48, UCase("NUM " & Chr$(X))) Then Exit Sub
Next X
If CompKey(8, "BACKSPACE") Then Exit Sub
If CompKey(9, "TAB") Then Exit Sub
If CompKey(13, "ENTER") Then Exit Sub
If CompKey(16, "SHIFT") Then Exit Sub
If CompKey(17, "STRG") Then Exit Sub
If CompKey(18, "ALT") Then Exit Sub
If CompKey(19, "PAUSE") Then Exit Sub
If CompKey(27, "ESC") Then Exit Sub
If CompKey(33, "PAGE UP") Then Exit Sub
If CompKey(34, "PAGE DOWN") Then Exit Sub
If CompKey(35, "ENDE") Then Exit Sub
If CompKey(36, "POS1") Then Exit Sub
If CompKey(37, "LEFT") Then Exit Sub
If CompKey(38, "UP") Then Exit Sub
If CompKey(39, "RIGHT") Then Exit Sub
If CompKey(40, "DOWN") Then Exit Sub
If CompKey(44, "DRUCK") Then Exit Sub
If CompKey(45, "INSERT") Then Exit Sub
If CompKey(46, "DEL") Then Exit Sub
If CompKey(144, "NUM") Then Exit Sub
If CompKey(145, "ROLLEN") Then Exit Sub
For X = 112 To 127
If CompKey(X, "F" & Str$(X - 111)) Then Exit Sub
Next X
End Sub
Do
ab()
Loop Until sTaste = "ESC"
End
Zusätzliche Informationen und Funktionen | |||||||
---|---|---|---|---|---|---|---|
|
|