Jump to content

Counting the number of times the bot clicks

Recommended Posts


I would like some way to count the number of times the bot clicks. My primary motive for this is that I want to make sure that the conditional sleeps are performing correctly i.e. after clicking on a tree the bot doesn't click again until the tree is dead. 

I took a look at BotMouseListener, and got that to work (in a somewhat hacky manner). 

Unfortunately, while that seems to be correctly counting my manual clicks on the screen, it is not recording the clicks that the bot itself makes. (AAARRGHRGHRGHR). 

I searched through the snippets and such but I wasn't able to find any post addressing this. 

Any help would be appreciated. 

(If someone wants to tell me the none hacky way of implementing BotMouseListener that would also be great)

ClickCounter File:

package Helpers;

import java.awt.event.MouseEvent;
import static java.awt.event.MouseEvent.MOUSE_CLICKED;

import org.osbot.rs07.input.mouse.BotMouseListener;
import org.osbot.rs07.script.MethodProvider;

public class ClickCounter extends BotMouseListener {

//    This allows us to reroute our output to the same log console as our main script.
//    The script writes, "ClickCounter.MP = this".
    public static MethodProvider MP = null;
    public static int clickCount = 0;

    public void checkMouseEvent(MouseEvent mouseEvent) {
        if (mouseEvent.getID() == MOUSE_CLICKED) {
            assert(MP != null);
            MP.log("MINE: Mouse Clicked!");


Script File:

package Attempt1;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import Helpers.ClickCounter;

@ScriptManifest(author="RS3141", info="Test1", logo="", name="Example Script 1", version=1)
public class ExampleScript1 extends Script {

    public void onStart() {

        // Allow the ClickCounter to log to the output.
        ClickCounter.MP = this;
        this.bot.addMouseListener(new ClickCounter());


    public int onLoop() throws InterruptedException {
        // Do stuff
		return 500;



Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...