求个VB代码
我想做个和按键精灵一样的东西 不知道怎么做 希望个大高手帮忙
先按数字键 5 延时1000毫秒 再按<Tab> 键 延时800毫秒 再按5次F1键 每次延时 850毫秒 完成后再延时 3000毫秒 再按4次F2键 每次延时840毫秒
完成后循环 (从按<Tab>开始) 最后每30分钟按1次数字键6
就是这样的意思 希望各位高手 出谋划策 最好连加哪个部件都说清楚 先谢谢了
参考答案:Dim StartTM As Single '保存当前的Timer的值,注意,下面的Timer和Timer1完全是两回事!
Private Sub Command1_Click()
Dim n As Integer
n = 0
SendKeys "5", True
waittime 1
Do
SendKeys "{Tab}", True
waittime 0.8
SendKeys "{F1}", True
waittime 0.85
SendKeys "{F1}", True
waittime 0.85
SendKeys "{F1}", True
waittime 0.85
SendKeys "{F1}", True
waittime 0.85
SendKeys "{F1}", True
waittime 3
SendKeys "{F2}", True
waittime 0.84
SendKeys "{F2}", True
waittime 0.84
SendKeys "{F2}", True
waittime 0.84
SendKeys "{F2}", True
waittime 0.84
n = n + 1
Loop Until n = 3 '循环3次
StartTM = Timer
Timer1.Interval = 1000
End Sub
Private Sub waittime(delay As Single) '延时用子过程
Dim starttime As Single
starttime = Timer
Do Until (Timer - starttime) > delay
DoEvents
Loop
End Sub
Private Sub Timer1_Timer()
If (Timer - StartTM > 1800) Then '每隔1秒检测一次,是否已间隔30分钟
SendKeys "6", True
StartTM = Timer
End If
End Sub