Keyboard simulator

(make program type text that was pasted in him)

Page 1 of 1

1 Replies - 2107 Views - Last Post: 17 November 2010 - 02:52 PM Rate Topic: -----

#1 EvilGrin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-September 09

Keyboard simulator

Posted 17 November 2010 - 01:30 PM

Hi, I'm just starting with java, and I always like to do something unusual to start with. So this time I have keyboard/keystroke simulator in mind.

The idea:

Make program in which I can paste certain text, or maybe a program that can read a text file, and then simulate
keystrokes and retype that text in active text box or text area.

The problem:
Don't have even the slightest idea about how to do it. I read something on scanner class, and I figured I can use it
to read from files, but don't know how to make it "type" text from that file to a certain text box. I'm coming from
pascal, so I wanted to learn a bit more about that kind of stuff.

Any kind of help appreciated! ^^

Is This A Good Question/Topic? 0
  • +

Replies To: Keyboard simulator

#2 EvilGrin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-September 09

Re: Keyboard simulator

Posted 17 November 2010 - 02:52 PM

Just to write down what I've figured out so far.

So, I know how to read a text file. Only thing I need to figure out right now, is how to make program type that text back in selected text area.


import java.util.Scanner;
import java.io.File;
import java.io.IOException;

public class InputOutput {

  public static void main (String[] arg)throws IOException{
  
    Scanner s = new Scanner(new File("fileName.fileExtension"));
    
    //I can use this while loop to get all text lines from a file into a string. Right now, I'm just printing them 
      out by using hasNext function, that detects next line in a text file.

    while (s.hasNext()) { 
    
      System.out.println(s.nextLine());
    
    }
  
  }

}



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1