vb.net SendKeys.Send(TextBox1.Text)发送慢速模拟写入

时间:2016-05-07 03:48:18

标签: vb.net

vb.net SendKeys.Send(TextBox1.Text)发送慢速模拟写入

Process.Start("notepad")

SendKeys.Send(TextBox1.Text)

我写了TextBox1中的内容,写得非常慢 我想模拟写作团结的人

1 个答案:

答案 0 :(得分:0)

Sub SimulateWriting() ' Call me to start
    With Timer ' Initialize the timer
        .BeginInit()
        .AutoReset = True
        .Enabled = True
        .InitializeLifetimeService()
        .EndInit()
        .Start() ' Start typing now
    End With
    Process.Start("notepad") ' Start Notepad
End Sub
WithEvents Timer As New Timers.Timer(1000) ' The timer with its interval set to 1 second (aka 1000 milliseconds)
Sub Timer_Tick(sender As Object, e As System.Timers.ElapsedEventArgs) Handles Timer.Elapsed ' When one second is elapsed
    Static Counter As Integer = 0 ' Stores the character position to sendkey
    SendKeys.Send(Textbox1.Text(Counter)) ' Sends the key
    Counter += 1 ' Update the counter
    If Counter >= Textbox1.Text.Length Then ' All characters are sent
        Counter = 0 ' Reset the counter
        Timer.Stop() ' No need to send keys again
    End If
End Sub