Skip to content

Instantly share code, notes, and snippets.

@vs4vijay
Created June 17, 2010 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vs4vijay/441821 to your computer and use it in GitHub Desktop.
Save vs4vijay/441821 to your computer and use it in GitHub Desktop.
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