Questions

Visual Basic "SendKeys" command question

Tags: Windows, Software
+
0 Votes

Visual Basic "SendKeys" command question

Mutant-JD
Hello, its my first time here and I would like to ask a question.
I use Microsoft Visual Basic 2008 Express Edition and I am trying to build an Auto-Typer for my own use. I know how to use intervals (Timer1.Interval etc.) but is it possible to change the SPEED of the typing? I mean when auto-typer starts writing, at a notepad for example, writes too quickly. Personally I believe this has to do with the SendKeys, I think there should be a way to slow it down, pause it somehow or something...


Thanks a lot!

Member Answers

    • +
      0 Votes
      GeorgeJ0

      The best method would be using the SendKeys.SendWait Method. Use SendWait to send keystrokes or combinations of keystrokes to the active application and wait for the keystroke messages to be processed. You can use this method to send keystrokes to an application and wait for any processes that are started by the keystrokes to be completed. This can be important if the other application must finish before your application can continue.

      Public Shared Sub SendWait ( _
      keys As String _
      )

      Dim keys As String

      SendKeys.SendWait(keys)

      Source is MSDN - http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait(v=vs.90).aspx

      Another thing I can think of right now is maybe a timer. I am guessing you are trying to slow down each character. So we need to split the text into characters then we use a timer to control how fast we want to send the characters.

      Function to split string :-

      Dim a() As String
      Dim j As Integer
      a = TextBox1.Text.Split(Lf)

      For j = 0 To a.GetUpperBound(0)
      MsgBox(a(j))
      Next

      Then use a timer to send the characters at your desired pace.

      Hope this helps. :-)

      +
      0 Votes
      GeorgeJ0

      Sorry for posting again, I couldn't edit my previous post so replying again. You can use this code as well.

      Splitting a word into Character :

      Dim myArray As Char() = TextBox1.Text.ToCharArray()

      For i = 0 To myArray.GetUpperBound(0) - 1
      MsgBox(myArray(i))
      Next

    • +
      0 Votes
      GeorgeJ0

      The best method would be using the SendKeys.SendWait Method. Use SendWait to send keystrokes or combinations of keystrokes to the active application and wait for the keystroke messages to be processed. You can use this method to send keystrokes to an application and wait for any processes that are started by the keystrokes to be completed. This can be important if the other application must finish before your application can continue.

      Public Shared Sub SendWait ( _
      keys As String _
      )

      Dim keys As String

      SendKeys.SendWait(keys)

      Source is MSDN - http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait(v=vs.90).aspx

      Another thing I can think of right now is maybe a timer. I am guessing you are trying to slow down each character. So we need to split the text into characters then we use a timer to control how fast we want to send the characters.

      Function to split string :-

      Dim a() As String
      Dim j As Integer
      a = TextBox1.Text.Split(Lf)

      For j = 0 To a.GetUpperBound(0)
      MsgBox(a(j))
      Next

      Then use a timer to send the characters at your desired pace.

      Hope this helps. :-)

      +
      0 Votes
      GeorgeJ0

      Sorry for posting again, I couldn't edit my previous post so replying again. You can use this code as well.

      Splitting a word into Character :

      Dim myArray As Char() = TextBox1.Text.ToCharArray()

      For i = 0 To myArray.GetUpperBound(0) - 1
      MsgBox(myArray(i))
      Next