java获取鼠标位子和改动鼠标位子_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > java获取鼠标位子和改动鼠标位子

java获取鼠标位子和改动鼠标位子

 2013/9/5 18:14:41  弦上的福音  程序员俱乐部  我要评论(0)
  • 摘要:importjava.awt.MouseInfo;importjava.awt.Point;importjava.awt.Robot;importjava.text.DateFormat;importjava.text.SimpleDateFormat;publicclassScreenSaverFucker{publicstaticfinallongSLEEP=15000L;publicstaticfinalbooleanDEBUG=true;publicstaticintCOUNT
  • 标签:Java 鼠标
class="java" name="code">
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Robot;
import java.text.DateFormat;
import java.text.SimpleDateFormat;


public class ScreenSaverFucker {
	
	public static final long SLEEP = 15000L;
	
	public static final boolean DEBUG = true;
	
	public static int COUNT ;

	
	public static void main(String[] args) throws Exception  {
		Robot rbt = new Robot();
		for(COUNT = 1 ; true ; COUNT++){
			Point oldP = MouseInfo.getPointerInfo().getLocation();
			int move = 1 - ((COUNT & 1) << 1);
			
			System.out.println("COUNT:"+COUNT);
			System.out.println("move"+move);
			
			Point newP = new Point(oldP.x + move, oldP.y + move);
			rbt.mouseMove(newP.x, newP.y);
			if(DEBUG){
				log(oldP, newP);
			}
			Thread.sleep(SLEEP);
			
		}
	}
	
	public static void log(Point oldP, Point newP){
		String str = "(" + oldP.x + "," + oldP.y +")" + "\t >" +
					 "(" + newP.x + "," +newP.y + ")";
		DateFormat fmt = new SimpleDateFormat("[HH:mm:ss]");
		String date = fmt.format(System.currentTimeMillis());
		System.out.println(date + COUNT + "回目:\t" + str);
		
	}
	

}




发表评论
用户名: 匿名