[Guide] Making a C# Auto Typer

Get help with just about anything and everything NOT Warcraft related. Computers, consoles, phones, whatever!
User avatar
Small Sized Duck
Noob
Posts: 946
Joined: December 23rd, 2008, 11:27 pm
Title: LSD.
Location: Your Girlfriend's Pants.

[Guide] Making a C# Auto Typer

Post by Small Sized Duck »

Today I will teach you how to make a simple autotyper in C#.
Start off by starting a new project and naming it whatever you want.


Add some controls to the form:
- Button
- Textbox
- Timer

It really doesn't mater how you organize them, just make sure to make it look nice.

I've explained the functions in the code, so if you need references you know what they mean.

Double click on your button and enter the following code below into the button1_Click event

Code: Select all

//button1_Click

//Sets the timer's interval. Pretty straight forward.
timer1.Interval = 1000;

//Tells the computer to switch to the last window open.
SendKeys.Send("%{TAB}");

//Enable the timer and therefore starts the typing.
timer1.Enabled = true;


Now, anywhere between the public partial class Form1: Form tags, add this

Code: Select all

int count = 0;


Example:

Code: Select all

public partial class Form1 : Form
{
int count = 0;
}


Now, double click the timer to bring up it's tick event.

Code: Select all

//timer1_Tick


//Generates a random number. Important so it's undetectable.
Random randomnum = new Random();

//Temporarily disables the timer.
timer1.Enabled = false;

//Sets the timer's interval to a random number between 125 and 225.
timer1.Interval = randomnum.Next(125, 225);

//Checks if the length of the textbox text is greater than zero.
if (count < textBox1.Text.Length)
{

//Starts typing the textbox's text. Uses the counter to make sure there is text to type.
SendKeys.Send(textBox1.Text.Substring(count, 1));

//Increases the count by 1.
count++;

//Re-enables the timer.
timer1.Enabled = true;

}
//If there is nothing left to type.
else
{
count = 0;

//Hits the enter key.
SendKeys.Send("{Enter}");

}


Hit F5, type something in the text box, open up notepad, then click start.
If your autotyper is working, congratulations!
Image