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
  • Keyboard.holdKeyWhile() and Keyboard.holdKeyUntil() methods?


    wefwefwef222
     Share

    Recommended Posts

    Hi, maybe there's a way to do this, but I haven't been able to figure it out. Constructing a Robot class to hold a key down doesn't work for me, and using the Keyboard.type() method just isn't the same as pressing and holding a key down (for fast menu selection). Would it be possible to get this method in the API?

    Link to comment
    Share on other sites

    23 minutes ago, wefwefwef222 said:

    Hi, maybe there's a way to do this, but I haven't been able to figure it out. Constructing a Robot class to hold a key down doesn't work for me, and using the Keyboard.type() method just isn't the same as pressing and holding a key down (for fast menu selection). Would it be possible to get this method in the API?

    https://dreambot.org/javadocs/org/dreambot/api/methods/input/Keyboard.html#holdKey(char,org.dreambot.api.utilities.impl.Condition,long)

    Link to comment
    Share on other sites

    36 minutes ago, Neffarion said:

    Oops I forgot to mention that part... that method is broken (unless I'm doing something wrong).

    For example:

    Keyboard.holdKey('c', () -> false, 3000);

    Should hold c for 3 seconds, but it only enters c once, but doesn't hold it down. Not sure why... maybe I should make this a bug post instead.

    Link to comment
    Share on other sites

    17 hours ago, wefwefwef222 said:

    Oops I forgot to mention that part... that method is broken (unless I'm doing something wrong).

    For example:

    Keyboard.holdKey('c', () -> false, 3000);

    Should hold c for 3 seconds, but it only enters c once, but doesn't hold it down. Not sure why... maybe I should make this a bug post instead.

    I don't believe the method is supposed to "spam" the character, it just sets it as pressed until it timeouts or the condition is met

    What exactly are you talking about in "fast menu selection"?

    Link to comment
    Share on other sites

    On 9/30/2021 at 6:22 AM, Neffarion said:

    I don't believe the method is supposed to "spam" the character, it just sets it as pressed until it timeouts or the condition is met

    What exactly are you talking about in "fast menu selection"?

    It doesn't hold it down though. Imagine when you hold down a key on your keyboard... it starts repeating the character. Holding down "A" for 5 seconds would look something like "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA." Welp, it doesn't. Either way, the condition is not working correctly. Even if you do:

    Keyboard.holdSpace(() -> false, 5000);

    This has a condition which returns false, yet this method instantly returns after executing once. It *does* type the key (for example here, space) once, but no more than once. E.g.:

    log("1");
    Keyboard.holdSpace(() -> false, 5000);
    log("2");

     

    Output:

    • 12:37:03 PM: [SCRIPT] 1
    • 12:37:03 PM: [SCRIPT] 2

    Notice how the script doesn't wait 5 seconds... it moves to the second logger within the same timestamp second.

    Link to comment
    Share on other sites

    2 hours ago, wefwefwef222 said:

    It doesn't hold it down though. Imagine when you hold down a key on your keyboard... it starts repeating the character. Holding down "A" for 5 seconds would look something like "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA." Welp, it doesn't. Either way, the condition is not working correctly. Even if you do:

    Keyboard.holdSpace(() -> false, 5000);

    This has a condition which returns false, yet this method instantly returns after executing once. It *does* type the key (for example here, space) once, but no more than once. E.g.:

    log("1");
    Keyboard.holdSpace(() -> false, 5000);
    log("2");

     

    Output:

    • 12:37:03 PM: [SCRIPT] 1
    • 12:37:03 PM: [SCRIPT] 2

    Notice how the script doesn't wait 5 seconds... it moves to the second logger within the same timestamp second.

    Like I said, I don't think these methods are to be used for typing, you can use Keyboard.type() for that

    You can try for instance Keyboard.holdshift() to drop items for example and it works fine

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     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.