Programalama > JAVA - JSP

Etiketler: java, robot, class, örnegi

Ort. 0
Puan ver:
import java.io.*;
import java.awt.*;
import java.awt.event.*;

public class Robot1{
	public static void main(String[] args) throws Exception{
		Robot r = new Robot();
				
		Runtime.getRuntime().exec("notepad");
		Thread.sleep(1000);
		typeLine("I know who you are",r,false);
		r.delay(3000);
		for(int i=0; i<=18; i++){		
		r.keyPress(KeyEvent.VK_BACK_SPACE);
		r.keyRelease(KeyEvent.VK_BACK_SPACE);
		r.delay(200);
		}
		r.keyPress(KeyEvent.VK_ALT);
		r.keyPress(KeyEvent.VK_F4);
		r.keyRelease(KeyEvent.VK_F4);
		r.keyRelease(KeyEvent.VK_ALT);		
		
	}
	public static void typeLine(String s,Robot robot,boolean enter) throws Exception{
	    char[] array=s.toCharArray();
	    for(int i=0;i<array.length;i++){
	      Thread.sleep(100);
	      if(array[i]>='a'&&array[i]<='z'){
	        robot.keyPress((int)array[i]-(int)'a'+65);
	        robot.keyRelease((int)array[i]-(int)'a'+65);
	      }else if(array[i]==' '){
	        robot.keyPress(KeyEvent.VK_SPACE);
	        robot.keyRelease(KeyEvent.VK_SPACE);
	      }else if(array[i]>='A'&&array[i]<='Z'){
	        robot.keyPress(KeyEvent.VK_SHIFT);
	        robot.keyPress((int)array[i]-(int)'A'+65);
	        robot.keyRelease((int)array[i]-(int)'A'+65);
	        robot.keyRelease(KeyEvent.VK_SHIFT);
	      }else if(array[i]>='0'&&array[i]<='9'){
	        robot.keyPress(KeyEvent.VK_SHIFT);
	        robot.keyPress(KeyEvent.VK_0+(int)(array[i]-'0'));
	        robot.keyRelease(KeyEvent.VK_0+(int)(array[i]-'0'));
	        robot.keyRelease(KeyEvent.VK_SHIFT);
	      }
	    }
	    if(enter){
	      robot.keyPress(KeyEvent.VK_ENTER);
	      robot.keyRelease(KeyEvent.VK_ENTER);
	    }
    
  }
}


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.