VB编写自动重复按键的问题!
如:我按一下“a”键。随后系统自动会每隔1000毫秒自动重复按一次(循环)。请问内部代码该如何写呢?...
如:我按一下“a”键。随后系统自动会每隔1000毫秒自动重复按一次(循环)。请问内部代码该如何写呢?
展开
4个回答
2013-10-17
展开全部
添加两个Timer,第一个Enabled=True,Interval=100,第二个Enabled=Fasle,Interval=1000Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As IntegerPrivate Sub Timer1_Timer()
If GetAsyncKeyState(41) Then
Timer1.Enabled = Not Timer1.Enabled
Timer2.Enabled = Not Timer2.Enabled
End If
End SubPrivate Sub Timer2_Timer()
SendKeys "a"
End Sub
If GetAsyncKeyState(41) Then
Timer1.Enabled = Not Timer1.Enabled
Timer2.Enabled = Not Timer2.Enabled
End If
End SubPrivate Sub Timer2_Timer()
SendKeys "a"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-17
展开全部
在模块里加:Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal Scan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) 窗体:Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyA Then
Timer1.Enabled = True
End If
End SubPrivate Sub Form_Load()
Timer1.Interval = 1000
Form1.KeyPreview = True
End SubPrivate Sub Timer1_Timer()
Call keybd_event(65, 0, 0, 0)
End Sub
If KeyCode = vbKeyA Then
Timer1.Enabled = True
End If
End SubPrivate Sub Form_Load()
Timer1.Interval = 1000
Form1.KeyPreview = True
End SubPrivate Sub Timer1_Timer()
Call keybd_event(65, 0, 0, 0)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-17
展开全部
Public Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-17
展开全部
我用QQ发给你! 你采我
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询