Jump to content

mouse.pressKey some key codes not working?


Recommended Posts

Posted (edited)
16 minutes ago, Wacky Jacky said:

Can you explain what it is you are trying to do? Perhaps send a bit of code along.

gpWis5T.gif

@Override
public int onLoop() {
  if (getDialogues().isPendingOption()) {
    log("Option Pending");

    //Presses the key, keeps it pressed until release;
    getKeyboard().pressKey(KeyEvent.VK_1);

    if (getKeyboard().isKeyDown(KeyEvent.VK_1)) {
      log("Key is down");
      getKeyboard().releaseKey(KeyEvent.VK_1);
    } else {
      log("Key is not down");
    }

  }
  return random(1000,1200);
}


Since I am not sure what your goal is, if you want to press a key for dialog you need to use:

if (getDialogues().isPendingOption()) {
  log("Option Pending");
  getDialogues().selectOption(1);
}


And if you want to type numbers in chat:

@Override
public int onLoop() {
  getKeyboard().typeString("1"); 
  getKeyboard().typeEnter();
  return random(1000,1200);
}


Lmk ^^

Edited by Wacky Jacky
extra options
Posted

Pretty much just trying to hold down 'Num1' on the keyboard while I run a for loop and release after. 

        keyboard.pressKey(97);
        if(tabs.isOpen(Tab.INVENTORY)) {
            int myNum = (int) inventory.getAmount(Item);
            for (int i = 0; i < myNum; i++) {
                mouse.click(random(690, 720), random(430, 460), false);
                objects.closest(Object).interact();
            }
            keyboard.releaseKey(97);
        } else {
            tabs.open(Tab.INVENTORY);
        }

 

I use this in another script to drop items with shift and it works 

                keyboard.pressKey(16);
                for (int i = 0; i < myPattern.length; i++) {
                    getMouse().click(getInventory().getMouseDestination(myPattern[i]));
                }
                keyboard.releaseKey(16);

 

 

Posted
3 hours ago, Wacky Jacky said:

I am not sure what number 1 does, but I am kinda sure it is pressed 🤔

I must not be understanding something then. Should it not be spamming '1' in the chat (without entering) if the script is holding down the 1 key?
I'm pretty much just trying to tick cook karambwans by holding down 1 for when the cook option comes up and then clicking the raw karambwan onto the fire repeatedly until the inventory is cooked and then release 1.

Posted

You need to put the holding down key functionality in a new thread to get the functionality you're aiming for. The press key/release key stuff only sends a single input to the client respectively. typeContinualKey also works but to simulate holding key something like this if what you're looking for

while (true) {
	press key down
	release key
	sleep(30)
}

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...