求自动打字代码
用VB程序实现另一当前程序文本框打字效果像按键精灵一样的。
谢谢
Private Sub Command1_Click()
'使文本框2具有输入焦点
Text2.SetFocus
'开启定时器
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Interval = 200
Timer1.Enabled = False
Text2.Text = ""
End Sub
Private Sub Timer1_Timer()
Dim str1 As String
Dim str2 As String
Dim len1 As Integer
Static i As Integer
str1 = Text1.Text '显示信息
len1 = Len(str1)
'取得要显示的字符
str2 = Mid(str1, i + 1, 1)
'一个字一个字地显示
SendKeys str2
i = i + 1
If (i + 1) > len1 Then
SendKeys "{enter}" '换行
i = 0
End If
End Sub