benou | Code :
- import java.awt.*;
- import java.awt.event.*;
- import java.io.IOException;
-
- public class Test{
- //Create an array of keycode data
- static int keyInput[] = {
- KeyEvent.VK_F,
- KeyEvent.VK_O,
- KeyEvent.VK_R,
- KeyEvent.VK_M,
- KeyEvent.VK_A,
- KeyEvent.VK_T,
- KeyEvent.VK_SPACE,
- KeyEvent.VK_C,
- KeyEvent.VK_COLON,
- KeyEvent.VK_ENTER
- };//end keyInput array
-
- public static void main(String[] args)
- throws AWTException,IOException{
-
- //Start the Windows Notepad program running
- // in a separate process. It should become
- // the active window, capable of accepting
- // input from the keyboard.
- Runtime.getRuntime().exec("cmd" );
-
- //Get a Robot object that will be used to
- // enter characters into the Notepad document
- Robot robot = new Robot();
-
- //Enter the keycodes contained in the
- // keyInput array into the Notepad document.
- // Make the first character upper case and
- // the remaining characters lower case.
- robot.keyPress(KeyEvent.VK_SHIFT);
- for (int cnt2 = 0;
- cnt2 < keyInput.length; cnt2++){
- if(cnt2 > 0){
- robot.keyRelease(KeyEvent.VK_SHIFT);
- }//end if
- robot.keyPress(keyInput[cnt2]);
- //Insert a one-half second delay between
- // characters.
- robot.delay(200);
- }//end for loop
- System.out.println("DTC" );
- }//main
- }
|
Ne pas lancer, hein !!! (je précise pour les newbies qui auraient pas compris ...) Message édité par benou le 03-11-2003 à 14:48:27 ---------------
ma vie, mon oeuvre - HomePlayer
|