AutoTyper Tutorial
Ok today guys im gonna show you how to create a simple autotyper. Its one of the easiest projects you will make but you need to remember all the little things that make little projects professional.
Step1
You need to create a form similar to the one below.
Heres a list of what you need;
- 6x TextBoxes (1 Multi-line)
- 5x CheckBoxes (No Labels)
- 2x Buttons (Named Start and Stop)
- 1x Label (Named Interval)
- 1x Timer
Step2
Double click your start button and add this code;
[vb]
Timer1.interval = TextBox7.Text
Timer1.Start()
Button2.Enabled = True
Button1.Enabled = False[/vb]
This code starts the timer which in time will send the messages set-up.
Step3
Double click you stop button and add this code;
[vb]
Timer1.Stop()
Button2.Enabled = False
Button1.Enabled = True[/vb]
This code then stops the process by stopping the timer.
Step4
In the properties panel of your stop button, set enabled to false. This will stop us from clicking stop when there is nothing to stop.
Step5
Double click on Timer1 and add this code;
[vb]
If CheckBox1.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox1.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox2.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox2.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox3.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox3.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox4.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox4.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox5.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox5.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If[/code]
This code sends the messages in each of the text boxes dependant if the checkboxes next to them are checked or not.
(Note: You may need to change the name of the textbox codes depending on how you have laid out your form. Just make sure that checkbox1 and textbox1 are together, checkbox2 and textbox2 are together etc. This will stop confusion later.)
Step6
Test your program with Visual Studios inbuilt Debugging feature.
Step7
If it works, build the appplication then test it outside of Visual Studio
Step8
If it didnt work, then check your code against my full source code below.
Full Source Code
[vb]Public Class Form1
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.interval = TextBox7.Text
Timer1.Start()
Button2.Enabled = True
Button1.Enabled = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
Button2.Enabled = False
Button1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If CheckBox1.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox1.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox2.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox2.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox3.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox3.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox4.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox4.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox5.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox5.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
End Sub
End Class[/vb]
Thats it. Hope that was easy enough for you. Let me know if your struggling