Jump to content

Hide paint?


BrownBird

Recommended Posts

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
  • Like 2
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

 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
Link to comment
Share on other sites

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.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
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...