Alakazizam Posted December 24, 2024 Share Posted December 24, 2024 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. Quote Link to comment Share on other sites More sharing options...
Wacky Jacky Posted December 24, 2024 Share Posted December 24, 2024 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. Quote Link to comment Share on other sites More sharing options...
Wacky Jacky Posted December 24, 2024 Share Posted December 24, 2024 (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. @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 December 24, 2024 by Wacky Jacky extra options Quote Link to comment Share on other sites More sharing options...
Alakazizam Posted December 24, 2024 Author Share Posted December 24, 2024 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); Quote Link to comment Share on other sites More sharing options...
Wacky Jacky Posted December 24, 2024 Share Posted December 24, 2024 I am not sure what number 1 does, but I am kinda sure it is pressed Quote Link to comment Share on other sites More sharing options...
Alakazizam Posted December 24, 2024 Author Share Posted December 24, 2024 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. Quote Link to comment Share on other sites More sharing options...
Alakazizam Posted December 24, 2024 Author Share Posted December 24, 2024 (edited) I thought I got it sorted out with the typeContinualKey function but cant figure out how to get it holding the key while doing my loop Edited December 24, 2024 by Alakazizam Quote Link to comment Share on other sites More sharing options...
Nym Posted December 26, 2024 Share Posted December 26, 2024 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) } Quote Link to comment Share on other sites More sharing options...
yfoo Posted December 26, 2024 Share Posted December 26, 2024 I think this is a case where the numpad 1 and the 1 below the f keys are considered to be different. Quote Link to comment Share on other sites More sharing options...