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
  • Try asking for help in the chatbox
  • Mouse/Keyboard Input


    TheScripts
     Share

    Recommended Posts

    Hello,

     

    I'm working on a script that paints helpful information on the client but does not need to control the mouse and/or keyboard.

     

    Is there a way to prevent DreamBot from disabling mouse/keyboard input when the script is started?

     

    Thanks,

    TheScripts

    Link to comment
    Share on other sites

         Instance.getInstance().setKeyboardInputEnabled(true);
         Instance.getInstance().setMouseInputEnabled(true);
    

    Put this in your onResume(), and make your onStart() call your onResume()

    Link to comment
    Share on other sites

         Instance.getInstance().setKeyboardInputEnabled(true);
         Instance.getInstance().setMouseInputEnabled(true);
    

     

    Put this in your onResume(), and make your onStart() call your onResume()

     

    Thank you, this is exactly what I was looking for. :)

     

    I spent quite awhile browsing through the API documentation for this; but I see now that the Instance class does not reside in the API package hierarchy.

     

    I did, however, find an issue while testing this solution; It seems to work when the script is started, but the mouse and keyboard input become disabled if I pause then play the script.

     

    Test Script:

    public class Main extends AbstractScript {
    
        @Override
        public void onStart() {
            getRandomManager().disableSolver(RandomEvent.LOGIN);
            onResume();
        }
    
        @Override
        public void onResume() {
            Instance.getInstance().setMouseInputEnabled(true);
            Instance.getInstance().setKeyboardInputEnabled(true);
        }
    
        @Override
        public int onLoop() {
            return 1000;
        }
    
    }
    

    Any suggestions on how to correct this?

     

    On a side note: Is there an easy way to disable all random solvers, or do I need to disable each one separately? I tried calling getRandomManager().kill(), but the login solver seemed to be called first and the screen on the client went red (as if to login), and stayed that remained that way until the script was stopped.

     

    On a side side note: I've been using IntelliJ IDEA to create the JARs for my scripts, directly into the DreamBot script folder, and as soon as I run the script I can no longer delete the JAR or build a new copy over it. This results in me needed to kill DreamBot and relaunch it each time I want to rebuild the JAR. Any suggestions?

    Edited by TheScripts
    Link to comment
    Share on other sites

    add

    public void onPaused(){
    onResume();
    }
    

    Now when the script is paused, onResume() will also be called.

     

    Thank you for the suggestion. I have tested that method and it does not appear to solve the issue; the mouse and keyboard input is still disabled when I press the start button (after being paused).

     

    I have been able to, somewhat, get around the issue by adding the following to onLoop():

    if (!Instance.getInstance().isMouseInputEnabled()) {
        Instance.getInstance().setMouseInputEnabled(true);
    }
    if (!Instance.getInstance().isKeyboardInputEnabled()) {
        Instance.getInstance().setKeyboardInputEnabled(true);
    }
    
    Link to comment
    Share on other sites

     

    Thank you for the suggestion. I have tested that method and it does not appear to solve the issue; the mouse and keyboard input is still disabled when I press the start button (after being paused).

     

    I have been able to, somewhat, get around the issue by adding the following to onLoop():

    if (!Instance.getInstance().isMouseInputEnabled()) {
        Instance.getInstance().setMouseInputEnabled(true);
    }
    if (!Instance.getInstance().isKeyboardInputEnabled()) {
        Instance.getInstance().setKeyboardInputEnabled(true);
    }
    

    This should work but it's kind of memory intensive. You could probably get around this with a boolean system and a function that autocalls itself every 5 seconds or so that checks it (rather than checking it at each onLoop() ) but that's probably too complicated in itself and this should be ok.

    Link to comment
    Share on other sites

    This should work but it's kind of memory intensive. You could probably get around this with a boolean system and a function that autocalls itself every 5 seconds or so that checks it (rather than checking it at each onLoop() ) but that's probably too complicated in itself and this should be ok.

     

    This isn't memory intensive, all it does it change a Boolean to true or false. You could run it 10k a second and it won't have any impact.

    Link to comment
    Share on other sites

    This isn't memory intensive, all it does it change a Boolean to true or false. You could run it 10k a second and it won't have any impact.

    oh shit it is a boolean check, thought it was something else.

    Link to comment
    Share on other sites

     Share

    ×
    ×
    • 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.