VB写自动喊话器

来源:百度知道 编辑:UC知道 时间:2024/05/27 22:08:46
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Sub Command1_Click()
Text4 = Val(Text2) * Val(Text3)
Timer1.Enabled = True
MsgBox "自动喊话开启成功!谢谢您的使用!"
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
MsgBox "自动喊话已关闭!谢谢您的使用!"
End Sub

Private Sub Form_Load()
Command1.Caption = "开始自动喊话"
Command2.Caption = "结束自动喊话"
Timer1.Enabled = False
Text1.Text = "请在这里输入你要喊话的内容!"
End Sub

Private Sub Text3_Change()
For i = 0 To 1
If Val(Text1.Text) < 1 Or Val(Text1.Text) > 60 Then
MsgBox "请输1秒到60秒之间的数值,建议大于10秒!"
Text1.Text = ""
Text1.SetFocus
Exit Sub<

这里 SendKeys Text1.Text

随机数字可以改为:
SendKeys Text1.Text & Trim(Int(Rnd * 10))

如果固定一个循环可以

Private Sub Timer1_Timer()
Static k
k = k + 1
If k > 100 Then k =1
Timer1.Interval = Text4.Text
SendKeys Text1.Text & Trim(k)
SendKeys "{enter}"
End Sub