Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hide paint?

Featured Replies

Morning,

 

I have my MouseEvent, rectangle and booleans; I've tried to add the MouseLisenter with @Override yet nothing happens. Also when adding in MouseLisenter it adds other unneeded methods..

 

Any help is much appreciated thank you!

  • Developer

Morning,

 

I have my MouseEvent, rectangle and booleans; I've tried to add the MouseLisenter with @Override yet nothing happens. Also when adding in MouseLisenter it adds other unneeded methods..

 

Any help is much appreciated thank you!

 

Just add this to your onStart();

There are better ways to do it, but this is the most easy ^^

bot.addMouseListener(new MouseListener() {
 
            @Override
            public void mouseReleased(MouseEvent e) {
 
            }
 
            @Override
            public void mousePressed(MouseEvent e) {
               
            }
 
            @Override
            public void mouseClicked(MouseEvent arg0) {
 
            }
 
            @Override
            public void mouseEntered(MouseEvent arg0) {
 
            }
 
            @Override
            public void mouseExited(MouseEvent arg0) {
 
            }
        });

Edited by Khaleesi Scripts

Thanks, instead I just put it into my paint method to keep it clean smile.png

 

You wat?

 

Just making sure here; but you should under no circumstance register the event listener in onPaint :E

  • Author

You wat?

 

Just making sure here; but you should under no circumstance register the event listener in onPaint :E

 

Why not? lol.. It seems to be running just fine, is there something else I wouldn't know about?

Why not? lol.. It seems to be running just fine, is there something else I wouldn't know about?

Do you hate us or something? Has OSBot wronged you in any way?

  • Author

Do you hate us or something? Has OSBot wronged you in any way?

 

Oh my.. something occurred without me knowing :/

Why not? lol.. It seems to be running just fine, is there something else I wouldn't know about?

 

Well, onPaint is called 60 times per second (or 30, I don't remember).

 

The bot holds a collection of MouseListeners. Each time you register a listener, it's added to this collection. Registering 60 new mouse listeners per second is not only a fairly critical memory leak; but will increase your CPU usage over time, since every single mouse event has to be processed by the constantly growing number of listeners ;o.

 

I'm fairly surprised if you've been able to run it for ~30 minutes without seeing poor performance

 

Edited by FrostBug

  • Author

Well, onPaint is called 60 times per second (or 30, I don't remember).

 

The bot holds a collection of MouseListeners. Each time you register a listener, it's added to this collection. Registering 60 new mouse listeners per second is not only a fairly critical memory leak; but will increase your CPU usage over time, since every single mouse event has to be processed by the constantly growing number of listeners ;o.

 

I'm fairly surprised if you've been able to run it for ~30 minutes without seeing poor performance

 

 That's what I initially thought when you said this but I've ran it for about 3 hours today with CPU usage staying under 20%, now I'm not quite sure if that's high or not for a single script but it hasn't went past this at all.. Also been browsing the web and such, now for memory i haven't been keeping an eye on that. I will as of now!

 

Edit:

 

I think I understand why I haven't noticed any performance loss.. I have a memcleaner program installed; clearing it every 5 minutes.. 

Edited by BrownBird

 That's what I initially thought when you said this but I've ran it for about 3 hours today with CPU usage staying under 20%, now I'm not quite sure if that's high or not for a single script but it hasn't went past this at all.. Also been browsing the web and such, now for memory i haven't been keeping an eye on that. I will as of now!

 

Edit:

 

I think I understand why I haven't noticed any performance loss.. I have a memcleaner program installed; clearing it every 5 minutes.. 

 

Well, you can easily debug it.

 

int totalListeners = bot.getMouseListeners().size();

If this is constantly increasing, then you have a memory leak

 

Edited by FrostBug

Unfortunately there is a leak, I'll have to put it in my onStart

If it's because of the unwanted methods then create a class and extend mouse adapter. Then add that class to the bit's mouselistener

Well, onPaint is called 60 times per second (or 30, I don't remember).

 

The bot holds a collection of MouseListeners. Each time you register a listener, it's added to this collection. Registering 60 new mouse listeners per second is not only a fairly critical memory leak; but will increase your CPU usage over time, since every single mouse event has to be processed by the constantly growing number of listeners ;o.

 

I'm fairly surprised if you've been able to run it for ~30 minutes without seeing poor performance

 

 

I think onPaint (in this context) would be called 50 times per second (syncing with the RS client).

The reason we add our listeners in onStart is because otherwise we're creating a new listener 50 times per second (every 20ms), as well as assigning it to the bot to listen. When we click then, something along this would occur:

//when clicked
for (MouseListener ml : listeners) ml.onClick(mouseArgs);

So that means your mouse listeners will also be executing many times in tandem.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.