Jump to content

mouse.pressKey some key codes not working?


Alakazizam

Recommended Posts

8 hours ago, Alakazizam said:

So I've tested keyboard.pressKey(16) (shift key) and it works fine but if I try keyboard.pressKey(97) (Num 1) or any other character for that matter, it does not seem to go through.

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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);

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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