Aljosa Skorjanc

How to log mouse click?

Recommended Posts

Hello there!


I am working on a semi-machine-learning bot, which uses analysed data from real player gameplay to make the bot play like a real player. But, however, I am having issues by querying the mouse clicks which a bot makes during runtime.


For real player gameplay, I would have a class implement Java's MouseListener interface and then respond from there, but powerbot's mouse click methods obviously don't trigger Java's mouse events.


How could I query such mouse event?

Share this post

Link to post
Eldorado RuneScape Gold
3 hours ago, iDzn said:

Implement mouse listener 

I have implemented a mouse listener in the following manner already:

@Script.Manifest(name="CowKiller", description="Kills cows in Lubridge", properties = "author=Aljo; topic=999; client=4;")
public class CowKiller extends PollingScript<ClientContext> implements MouseListener {
    List<Task> tasksList = new ArrayList<>();
    AnalysedGameplayInfo analysedGameplayInfo;
    AnalysedGameplayInfo currentSessionInfo;

    public void poll() {

        Constants.sessionDuration = this.getTotalRuntime();
        if(Constants.windowWidth != ctx.input.getLocation().x || Constants.windowHeight!=ctx.input.getLocation().y) {
            Constants.updateWindowSize(ctx.input.getLocation().x, ctx.input.getLocation().y);


        long milliseconds = this.getTotalRuntime();
        long seconds = (milliseconds / 1000) % 60;
        Time.update(milliseconds, Math.round(seconds));

        //currentSessionInfo = RuntimeGameplayAnalyser.analyseRuntimeGameplayInfo(MouseMovementTracker.getMousePositionInfos(),
        //        CameraTracker.getCameraRotationInfos(), MouseClickTracker.getMouseButtonClickInfos());

        for(Task task : tasksList) {
            if(task.activate()) {

    public void start() {

        Constants.shouldBankCowhides = true;
        Constants.shouldBuryBones = true;

        System.out.println("AGPI loading stage");
        analysedGameplayInfo = AGPILoader.loadAGPI("F:\\Gaming\\Botting\\rsbotting\\Analysis\\CowKilling - looting\\session1\\analysed.txt");

       //tasksList.add(new RandomMouseMovement(ctx));
        tasksList.add(new CowKiller_Eat(ctx));
        tasksList.add(new BankDepositAll(ctx));
        tasksList.add(new CowKiller_Walk(ctx));
        //tasksList.add(new CowKiller_Attack(ctx));
        tasksList.add(new CowKiller_Loot(ctx));
        tasksList.add(new CowKiller_Attack(ctx));
        tasksList.add(new RandomMouseMovement(ctx));

    public void stop() {


    //mouse listener methods
    public void mouseClicked(MouseEvent e) {
        System.out.println("Mouse was clicked!");
        MouseClickTracker.addNewClickInfo(e, this.getTotalRuntime(), new Vector2f((float)ctx.input.getLocation().getX(), (float)ctx.input.getLocation().getY()));

    public void mousePressed(MouseEvent e) {


    public void mouseReleased(MouseEvent e) {


    public void mouseEntered(MouseEvent e) {


    public void mouseExited(MouseEvent e) {


But it doesn't log any mouse clicks.

Share this post

Link to post
10 hours ago, ShowtimeScripts said:

What sort of data are you trying to analyze? If you're storing clicks in isolation how is that helping you?

First, I've created a script which analyzes my gameplay (it analyzes where the mouse is the majority of the time, avg mouse position change frequency, etc.) and then stores this information inside a file. Then, I have this file read by my bot and then the bot is trying to achieve the same performance as the player (me).


One part of the analysis is also the analysis of the frequency of the mouse clicks (left, right, middle). To compare the bot with the information about the gameplay inside the file, I need to store all of the mouse clicks which are made by the bot, analyse them (ie, calculate the frequency of the mouse clicks the bot makes) and later compare it to the frequency of my clicks to see which button the bot needs to click more often to achieve a similar frequency).


I am having problems, however, with querying the mouse clicks which the bot makes.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.