Wednesday, 18 May 2016

A program which types automatically by its own

Image result for ghostHey guys, Today, I am going to show you all how to type like a Ghost! I am kidding!
But have you ever wondered to create a program which can run by its own and types texts in an notepad file?
Yeah, you heard it write! Today, I am going to show you how you can type artificially using a program code written in java. I will make use of the java.awt.Robot and java.awt.event.KeyEvent classes to achieve my aim.

Here is the code :

import java.awt.Robot;
import java.awt.event.KeyEvent;

public class TypingArtificially 
{
public static void main(String args[])
{
	try
	{
	Runtime.getRuntime().exec("notepad.exe");
	Thread.sleep(2000);
	Robot r=new Robot();
	r.keyPress(KeyEvent.VK_Y);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_O);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_U);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_SPACE);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_R);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_SPACE);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_H);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_A);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_C);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_K);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_E);
	Thread.sleep(500);
	r.keyPress(KeyEvent.VK_D);
	
	}
	catch(Exception e)
	{
		System.out.println(e);
	}
}
}


Compile the program and enjoy sharing with your friends !

0 comments :

Post a Comment