Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import org.tribot.api.General;
- import org.tribot.api.input.DynamicMouse;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.types.generic.CustomRet_0P;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- import java.awt.*;
- @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.")
- public class SendMoveEvent extends Script implements Painting {
- Point finish = new Point();
- Point start = new Point(700, 470);
- @Override
- public void run() {
- this.setLoginBotState(false);
- Mouse.setSpeed(50);
- // A thread that artificially moves the destination point to force DynamicMouse to generate new mouse paths.
- Thread pointMover = new Thread(() -> {
- while (!Thread.interrupted()) {
- finish = new Point(General.random(0, 100), General.random(0, 100));
- sleep(100);
- }
- });
- pointMover.start(); // Removing this line will make the motion work because Tribot does not need to generate a
- // new spline and as a result can continue along the original one without having to revert
- // to a new starting point.
- Mouse.move(start);
- Mouse.sendPress(start, 2); // Removing this line will make the mouse movement work smoothly because Tribot can
- // now properly track the mouse and as a result will have correct starting point
- // data for any newly generated mouse paths.
- CustomRet_0P<Point> livePoint = new CustomRet_0P<Point>() {
- @Override
- public Point ret() {
- return finish;
- }
- };
- DynamicMouse.move(livePoint);
- Mouse.sendRelease(livePoint.ret(), 2);
- }
- @Override
- public void onPaint(Graphics G) {
- G.setColor(Color.RED);
- G.fillOval(finish.x - 4, finish.y - 4, 8, 8);
- G.setColor(Color.GREEN);
- G.fillOval(start.x - 4, start.y - 4, 8, 8);
- }
- }
Add Comment
Please, Sign In to add comment