Created
June 17, 2010 07:55
-
-
Save vs4vijay/441821 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.event.*; | |
import java.awt.*; | |
class Mouse implements Runnable | |
{ | |
static Robot r; | |
static Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();; | |
public static void main(String[] args) throws Exception | |
{ | |
Mouse m = new Mouse(); | |
Thread t = new Thread(m); | |
t.start(); | |
r = new Robot(); | |
System.out.println(dim.width +":"+ dim.height); | |
} | |
public void run() | |
{ | |
try | |
{ | |
while(true) | |
{ | |
int xd = dim.width;int yd = dim.height; | |
int x = MouseInfo.getPointerInfo().getLocation().x; | |
int y = MouseInfo.getPointerInfo().getLocation().y; | |
// System.out.println(x +":"+ y); | |
//Runtime.getRuntime().exec("title hi"); | |
if(x < 7) | |
r.mouseMove(xd,y); | |
if(y < 7) | |
r.mouseMove(x,yd); | |
if(x + 7 > xd) | |
r.mouseMove(0,y); | |
if(y + 7 > yd) | |
r.mouseMove(x,0); | |
} | |
} | |
catch (Exception e) | |
{ | |
System.out.println(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment