Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (â‹®) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

mouse.pressKey some key codes not working?

Featured Replies

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.

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.

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

  • Author

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

 

 

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

  • Author
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.

  • Author

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 by Alakazizam

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

I think this is a case where the numpad 1 and the 1 below the f keys are considered to be different. 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.