icekontroi

Untitled

Aug 9th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. package scripts;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.input.DynamicMouse;
  5. import org.tribot.api.input.Mouse;
  6. import org.tribot.api.types.generic.CustomRet_0P;
  7. import org.tribot.script.Script;
  8. import org.tribot.script.ScriptManifest;
  9. import org.tribot.script.interfaces.Painting;
  10.  
  11. import java.awt.*;
  12.  
  13. @ScriptManifest(authors = { "IceKontroI" }, category = "@ Util", name = "Dynamic Mouse Movement Test", version = 0.01, description = "TRiBot is unable to dynamically move the mouse while a button is being pressed as is proven by this script. It moves back to the point where the button was originally pressed because it does not register drag movements as a change in mouse position.")
  14.  
  15. public class SendMoveEvent extends Script implements Painting {
  16.  
  17. Point finish = new Point();
  18. Point start = new Point(700, 470);
  19.  
  20. @Override
  21. public void run() {
  22.  
  23. this.setLoginBotState(false);
  24.  
  25. Mouse.setSpeed(50);
  26.  
  27. // A thread that artificially moves the destination point to force DynamicMouse to generate new mouse paths.
  28.  
  29. Thread pointMover = new Thread(() -> {
  30.  
  31. while (!Thread.interrupted()) {
  32.  
  33. finish = new Point(General.random(0, 100), General.random(0, 100));
  34.  
  35. sleep(100);
  36. }
  37. });
  38.  
  39. pointMover.start(); // Removing this line will make the motion work because Tribot does not need to generate a
  40. // new spline and as a result can continue along the original one without having to revert
  41. // to a new starting point.
  42.  
  43. Mouse.move(start);
  44.  
  45. Mouse.sendPress(start, 2); // Removing this line will make the mouse movement work smoothly because Tribot can
  46. // now properly track the mouse and as a result will have correct starting point
  47. // data for any newly generated mouse paths.
  48.  
  49. CustomRet_0P<Point> livePoint = new CustomRet_0P<Point>() {
  50. @Override
  51. public Point ret() {
  52. return finish;
  53. }
  54. };
  55.  
  56. DynamicMouse.move(livePoint);
  57.  
  58. Mouse.sendRelease(livePoint.ret(), 2);
  59. }
  60.  
  61. @Override
  62. public void onPaint(Graphics G) {
  63.  
  64. G.setColor(Color.RED);
  65. G.fillOval(finish.x - 4, finish.y - 4, 8, 8);
  66.  
  67. G.setColor(Color.GREEN);
  68. G.fillOval(start.x - 4, start.y - 4, 8, 8);
  69. }
  70. }
Add Comment
Please, Sign In to add comment