Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Correctly cancel a mouse/keyboard event (Maybe bug?)


    orange451

    Recommended Posts

    Hello, 

     

    I am messing with keyevent's and mouseevent's in my script. They work perfectly fine for capturing the input, however, I am not able to cancel them from reaching the game.

     

    I've created a GUI that looks like this:

    BfSpkgv.png

     

    All of the buttons function properly. HOWEVER, they still affect the game below. From the API of the MouseEvent and KeyEvent, if I call "consume()" it should block the event from reaching its source, but that does not seem to work properly. For example. If I press the X button on the window, I will start walking towards that red chair (even though the mouse event is consumed).

     

    Any help would be appreciated.

    Link to comment
    Share on other sites

    Use this under an OnMouseEnter listener

    getClient().getInstance().setMouseInputEnabled(false);

     

    And this under an OnMouseExit listener

    getClient().getInstance().setMouseInputEnabled(true);

    Link to comment
    Share on other sites

    1 minute ago, orange451 said:

    That won't work. My gui isn't external. It's painted ontop of the client. There is no enter or exit event fired when mousing over it.

    Make your own mouse listener and define the GUI box boundaries.

    Another option is to detect onMousePress (not onMouseClick) and do the mouse-disabling there

    Edit: I think by the time onMousePress gets called the click will be already sent to the game screen, so no this is probably not a solution.

    Link to comment
    Share on other sites

    Furthermore, setMouseInputEnabled/Disabled() wont work because my gui solution relies on mouse input being enabled to read it in the first place. Like I said, it's not an external window. It's literally painted on top of the client.

     

    I really feel like event.consume() should be the appropriate way to solve this.

    Link to comment
    Share on other sites

    Another way to achieve is this creating your GUI on a borderless frame/window instead of building it inside onPaint

    Edit: If your solution relies on the mouse input being enabled then you're doing something wrong. I remember being able to click on the GUI elements drawn via onPaint without any problems with the client's mouse input being enabled or not.

    Link to comment
    Share on other sites

    Unfortunately, that would be a mess with positioning. I want it to feel like it's part of runescape. i.e. if the runescape window moves, any of my windows will move with it.

    Link to comment
    Share on other sites

    2 minutes ago, orange451 said:

    Unfortunately, that would be a mess with positioning. I want it to feel like it's part of runescape. i.e. if the runescape window moves, any of my windows will move with it.

    You can achieve that via code as well, drag listeners.

    Link to comment
    Share on other sites

    5 minutes ago, orange451 said:

    That's getting much more hacky than properly implementing a consumed event into the bot, no?

    You're making a paint GUI that looks like runescape's original XD

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.