用vb编一段小程序,有追加分100分
让电脑反复执行:空格键,间隔0.5秒,方向键下,间隔0.5,回车键,间隔,方向左,方向左键,回车,回车,空格,空格,空格,ESC之间都有点间隔就这些了就是帮我编个代码,模...
让电脑反复执行:
空格键,间隔0.5秒,方向键下,间隔0.5,回车键,间隔,方向左,方向左键,回车,回车,空格,空格,空格,ESC
之间都有点间隔
就这些了
就是帮我编个代码, 模拟键盘操作
需要,循环。。。。。。我切到另一个窗口时,一直执行 展开
空格键,间隔0.5秒,方向键下,间隔0.5,回车键,间隔,方向左,方向左键,回车,回车,空格,空格,空格,ESC
之间都有点间隔
就这些了
就是帮我编个代码, 模拟键盘操作
需要,循环。。。。。。我切到另一个窗口时,一直执行 展开
6个回答
展开全部
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To 10
Presskey i
Next
End Sub
Private Sub Presskey(Index As Integer)
Dim t As Single
t = Timer
Do Until Timer - t - 0.5 > 0
DoEvents
Loop
Select Case Index
Case 0
SendKeys " " '空格键
Case 1
SendKeys "{DOWN}" '方向键下
Case 2
SendKeys "{ENTER}" '回车键
Case 3
SendKeys "{LEFT}" '方向左
Case 4
SendKeys "{LEFT}" '方向左
Case 5
SendKeys "{ENTER}" '回车键
Case 6
SendKeys "{ENTER}" '回车键
Case 7
SendKeys " " '空格键
Case 8
SendKeys " " '空格键
Case 9
SendKeys " " '空格键
Case 10
SendKeys "{ESC}" 'ESC
End Select
End Sub
Dim i As Integer
For i = 0 To 10
Presskey i
Next
End Sub
Private Sub Presskey(Index As Integer)
Dim t As Single
t = Timer
Do Until Timer - t - 0.5 > 0
DoEvents
Loop
Select Case Index
Case 0
SendKeys " " '空格键
Case 1
SendKeys "{DOWN}" '方向键下
Case 2
SendKeys "{ENTER}" '回车键
Case 3
SendKeys "{LEFT}" '方向左
Case 4
SendKeys "{LEFT}" '方向左
Case 5
SendKeys "{ENTER}" '回车键
Case 6
SendKeys "{ENTER}" '回车键
Case 7
SendKeys " " '空格键
Case 8
SendKeys " " '空格键
Case 9
SendKeys " " '空格键
Case 10
SendKeys "{ESC}" 'ESC
End Select
End Sub
展开全部
在窗体添加时钟 Timer1
Timer1.Interval = 500
Dim Index As Integer'窗体级变量
Private Sub Form_Load()
Index = 0
End Sub
Private Sub Timer1_Timer()
If Index = 0 Then
SendKeys " ", True '空格键
Index = 1
ElseIf Index = 1 Then
SendKeys "{DOWN}", True '方向键下
Index = 2
ElseIf Index = 2 Then
SendKeys "{ENTER}", True '回车键
Index = 2
ElseIf Index = 3 Then
SendKeys "{LEFT}", True '方向左
Index = 3
ElseIf Index = 4 Then
SendKeys "{LEFT}", True '方向左
Index = 5
ElseIf Index = 5 Then
SendKeys "{ENTER}", True '回车键
Index = 6
ElseIf Index = 6 Then
SendKeys "{ENTER}", True '回车键
Index = 7
ElseIf Index = 7 Then
SendKeys " ", True '空格键
Index = 8
ElseIf Index = 8 Then
SendKeys " ", True '空格键
Index = 9
ElseIf Index = 9 Then
SendKeys " ", True '空格键
Index = 10
ElseIf Index = 10 Then
SendKeys "{ESC}", True 'ESC
Index = 0
End If
End Sub
Timer1.Interval = 500
Dim Index As Integer'窗体级变量
Private Sub Form_Load()
Index = 0
End Sub
Private Sub Timer1_Timer()
If Index = 0 Then
SendKeys " ", True '空格键
Index = 1
ElseIf Index = 1 Then
SendKeys "{DOWN}", True '方向键下
Index = 2
ElseIf Index = 2 Then
SendKeys "{ENTER}", True '回车键
Index = 2
ElseIf Index = 3 Then
SendKeys "{LEFT}", True '方向左
Index = 3
ElseIf Index = 4 Then
SendKeys "{LEFT}", True '方向左
Index = 5
ElseIf Index = 5 Then
SendKeys "{ENTER}", True '回车键
Index = 6
ElseIf Index = 6 Then
SendKeys "{ENTER}", True '回车键
Index = 7
ElseIf Index = 7 Then
SendKeys " ", True '空格键
Index = 8
ElseIf Index = 8 Then
SendKeys " ", True '空格键
Index = 9
ElseIf Index = 9 Then
SendKeys " ", True '空格键
Index = 10
ElseIf Index = 10 Then
SendKeys "{ESC}", True 'ESC
Index = 0
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个很简单的,但是要实际可用还要加入一些代码,比如隐藏vb本窗口,让接受按键的窗口在前台等。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个不难,就是麻烦
从网上找的
Dim i As Integer
For i = 0 To 10
Presskey i
Next
End Sub
Private Sub Presskey(Index As Integer)
Dim t As Single
t = Timer
Do Until Timer - t - 0.5 > 0
DoEvents
Loop
Select Case Index
Case 0
SendKeys " " '空格键
Case 1
SendKeys "{DOWN}" '方向键下
Case 2
SendKeys "{ENTER}" '回车键
Case 3
SendKeys "{LEFT}" '方向左
Case 4
SendKeys "{LEFT}" '方向左
Case 5
SendKeys "{ENTER}" '回车键
Case 6
SendKeys "{ENTER}" '回车键
Case 7
SendKeys " " '空格键
Case 8
SendKeys " " '空格键
Case 9
SendKeys " " '空格键
Case 10
SendKeys "{ESC}" 'ESC
End Select
从网上找的
Dim i As Integer
For i = 0 To 10
Presskey i
Next
End Sub
Private Sub Presskey(Index As Integer)
Dim t As Single
t = Timer
Do Until Timer - t - 0.5 > 0
DoEvents
Loop
Select Case Index
Case 0
SendKeys " " '空格键
Case 1
SendKeys "{DOWN}" '方向键下
Case 2
SendKeys "{ENTER}" '回车键
Case 3
SendKeys "{LEFT}" '方向左
Case 4
SendKeys "{LEFT}" '方向左
Case 5
SendKeys "{ENTER}" '回车键
Case 6
SendKeys "{ENTER}" '回车键
Case 7
SendKeys " " '空格键
Case 8
SendKeys " " '空格键
Case 9
SendKeys " " '空格键
Case 10
SendKeys "{ESC}" 'ESC
End Select
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2009-02-28
展开全部
用timer事件啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我没有听懂你什么意思可以说详细些吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询