Created
July 17, 2011 05:54
-
-
Save brand-it/1087252 to your computer and use it in GitHub Desktop.
I cool mouse robot system that works great. May work for you as well.
This file contains 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
public class MouseRobot { | |
private void mouseRebotReplace(MouseEvent e) { | |
int x = e.getX() - pCenterX; | |
int y = e.getY() - pCenterY; | |
if (!isPaused) { | |
if (mouseX < 0) { | |
mouseX = 0; | |
} else if (mouseX > pWidth) { | |
mouseX = pWidth; | |
} else if (mouseY < 0) { | |
mouseY = 0; | |
} else if (mouseY > pHeight) { | |
mouseY = pHeight; | |
} else { | |
mouseX += x; | |
mouseY += y; | |
} | |
try { | |
robot = new Robot(); | |
robot.mouseMove(mouseCenterX, mouseCenterY); | |
} catch (AWTException e1) { | |
e1.printStackTrace(); | |
} | |
} | |
} | |
private void mouseRebotReplace(MouseEvent e) { | |
int x = e.getX() - pCenterX; | |
int y = e.getY() - pCenterY; | |
if (!isPaused) { | |
if (mouseX < 0) { | |
mouseX = 0; | |
} else if (mouseX > pWidth) { | |
mouseX = pWidth; | |
} else if (mouseY < 0) { | |
mouseY = 0; | |
} else if (mouseY > pHeight) { | |
mouseY = pHeight; | |
} else { | |
mouseX += x; | |
mouseY += y; | |
} | |
try { | |
robot = new Robot(); | |
robot.mouseMove(mouseCenterX, mouseCenterY); | |
} catch (AWTException e1) { | |
e1.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment