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
  • pressKey/releaseKey/holdKey functions?


    holic

    Recommended Posts

    Hey all,

    I've been going through the javadocs tirelessly trying to find any sort of pressKey or holdKey type functions with no luck.

    I know not everything DreamBot is in the docs (like setDrawMouse) so I thought I'd ask about it.

    If there isn't a method with the current API, is there something along the lines of this that I could do instead?

    (new KeyboardEvent(getClient().getInstance(), "", false)).pressSpecialKey(KeyEvent.VK_CONTROL);

     

    I want to be able to hold control and click at the same time to sprint.

    Link to comment
    Share on other sites

    You may be able to use something similar to this, though I haven't been able to test it.

    Instance instance = getClient().getInstance();
    Canvas canvas = instance.getCanvas();
    Inventory inventory = getInventory();
    
    instance.setKeyboardInputEnabled(true);
    mouse.getMouseSettings();
    canvas.dispatchEvent(new KeyEvent(canvas, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, KeyEvent.VK_CONTROL, KeyEvent.CHAR_UNDEFINED));
    	//code
    canvas.dispatchEvent(new KeyEvent(canvas, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), 0, KeyEvent.VK_CONTROL, KeyEvent.CHAR_UNDEFINED));
    instance.setKeyboardInputEnabled(false);

     

    Link to comment
    Share on other sites

    1 hour ago, StonedFarmer said:

    You may be able to use something similar to this, though I haven't been able to test it.

    Thanks StonedFarmer, that gives me a good starting point. I'll report back if I figure out a working method.

    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.