dc0qdguZU8R50JJu Posted December 9, 2020 Posted December 9, 2020 I'm lost on how this part of the API works. I'm trying to do something on the following triggers: - Mouse down; - Mouse movement (can be done with getMouse().getPosition(); maybe there's a better way?; - Mouse up; - Mouse click (?); might be the combination of mouse down and up; - Mouse drag (?); might be the combination of mouse down and mouse movement. Now, I have found the BotMouseListener and the checkMouseEvent which seems promising, but I have not a single clue how to implement it. A push in the right direction or some code snippets would be greatly appreciated!
Camaro Posted December 9, 2020 Posted December 9, 2020 BotMouseListener is a class than can be used to record your mouse clicks. In order to recreate them, use the ClientMouseEventHandler import org.osbot.rs07.input.mouse.BotMouseListener; import org.osbot.rs07.script.Script; import java.awt.event.MouseEvent; public class MouseHandler extends Script { private final BotMouseListener mouseListener = new BotMouseListener() { @Override public void checkMouseEvent(MouseEvent mouseEvent) { // called when you click the canvas } }; @Override public void onStart() { getBot().addMouseListener(mouseListener); } @Override public int onLoop() throws InterruptedException { // generate a mouse event getBot().getMouseEventHandler().generateBotMouseEvent(...); return 1000; } @Override public void onExit() throws InterruptedException { getBot().removeMouseListener(mouseListener); } } https://osbot.org/api/org/osbot/rs07/input/mouse/ClientMouseEventHandler.html
dc0qdguZU8R50JJu Posted December 10, 2020 Author Posted December 10, 2020 20 hours ago, Camaro said: BotMouseListener is a class than can be used to record your mouse clicks. In order to recreate them, use the ClientMouseEventHandler import org.osbot.rs07.input.mouse.BotMouseListener; import org.osbot.rs07.script.Script; import java.awt.event.MouseEvent; public class MouseHandler extends Script { private final BotMouseListener mouseListener = new BotMouseListener() { @Override public void checkMouseEvent(MouseEvent mouseEvent) { // called when you click the canvas } }; @Override public void onStart() { getBot().addMouseListener(mouseListener); } @Override public int onLoop() throws InterruptedException { // generate a mouse event getBot().getMouseEventHandler().generateBotMouseEvent(...); return 1000; } @Override public void onExit() throws InterruptedException { getBot().removeMouseListener(mouseListener); } } https://osbot.org/api/org/osbot/rs07/input/mouse/ClientMouseEventHandler.html Thank you so much, works like a charm. 1