我有一个简单的完成程序,但我想再添加一个功能,但我不知道如何。我设置为在选择文本字段时每7秒自动发送一条消息,当然重复该消息。我想要它做的是在两个单独的消息之间交替,而只是重复一个消息。我希望新程序以12秒的间隔发布。你能帮助我吗?这是我的编码。
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
SendKeys.Send(TextBox1.Text)
SendKeys.Send("{ENTER}")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer1.Interval = (TextBox2.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
End Sub
End Class
答案 0 :(得分:0)
更改此代码:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
SendKeys.Send(TextBox1.Text)
SendKeys.Send("{ENTER}")
End Sub
要
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If TextBox1.Text="Text1" then
TextBox1.Text="Text2"
Else
TextBox1.Text="Text1"
End If
SendKeys.Send(TextBox1.Text)
SendKeys.Send("{ENTER}") End Sub
至于计时器间隔,只需通过文本框TextBox2.Text
设置(如果这是你的代码,你怎么不知道这个?)