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



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

Process.Start("notepad")
SendKeys.Send(TextBox1.Text)

我写的是TextBox1中的内容,写得很慢我想模拟编写联合人

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

最新更新