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.

Simulate holding down spacebar

Featured Replies

Hey,

I am writing a script that has to do a lot of talking with NPC's. In order to speed this up I want to simulate holding down the spacebar, but I can't seem to get it working.

The build in Dialogues class does press spacebar to continue, but doesn't hold it down.

The Keyboard class has a pressKey() method but this also doesn't seem to hold down spacebar.

My question; is it possible to simulate holding down the spacebar in dialogues?

Thanks in advance!

 

edit:

Found a solution myself!

public void holdSpacebar() throws InterruptedException {
	while (getDialogues().isPendingContinuation()) {
		getKeyboard().pressKey(' ');
		sleep(30);
	}
	getKeyboard().releaseKey(' ');
}

By testing I found that a key gets repeated about 2000 times a minute on Windows 10 with the repeat rate set to max in keyboard properties. This translates to a key press every 30ms.

This method seems to have the same behavior as a human holding down spacebar. The talking process in my script seems to be sped up by about 100%!

Edited by MALS

if (getDialogues().isPendingContinuation()) {
            getDialogues().clickContinue();
}

edit: im not sure if thats what you want 

 

Edited by FuryShark

  • Author
5 minutes ago, FuryShark said:

if (getDialogues().isPendingContinuation()) {
            getDialogues().clickContinue();
}

edit: im not sure if thats what you want 

 

Nope, this would press the spacebar repeatedly and not hold it :(

8 minutes ago, MALS said:

Nope, this would press the spacebar repeatedly and not hold it :(

Any particular reason as to why it should hold the key and not just press it?

  • Author
11 minutes ago, Rays said:

Any particular reason as to why it should hold the key and not just press it?

It's about 100% faster in my case. Simulating a spacebar press 100x a second would also work, but thats not something what humans do.

Edited by MALS

4 minutes ago, MALS said:

It's about 100% faster in my case. Simulating a spacebar press 100x a second would also work, but thats not something what humans do.

keyboard class

1 hour ago, MALS said:

Nope, this would press the spacebar repeatedly and not hold it :(

 

You should have a look at the conditional sleep class

 

  if (getDialogues().isPendingContinuation()) {

   //hold space
   getKeyboard().pressKey(KeyEvent.VK_SPACE);

   int timeout = 1600; //2 tick surpassed + 400ms ping compensate
   int sleepTime = 700; //1 tick surpassed + 100ms ping compensate

   //sleep until isPendingContinuation() == false
   new ConditionalSleep(timeout, sleepTime) {
    @Override
    public boolean condition() throws InterruptedException {
     return !getDialogues().isPendingContinuation();
    }
   }.sleep();

   //release space
   getKeyboard().releaseKey(KeyEvent.VK_SPACE);

  }

 

Edited by Zappster

2 hours ago, Rays said:

Any particular reason as to why it should hold the key and not just press it?

way more efficient when you need to run through 100 dialogues then having it press spacebar each time a dialogue pops up

  • Author
8 hours ago, Zappster said:

 

You should have a look at the conditional sleep class

 


  if (getDialogues().isPendingContinuation()) {

   //hold space
   getKeyboard().pressKey(KeyEvent.VK_SPACE);

   int timeout = 1600; //2 tick surpassed + 400ms ping compensate
   int sleepTime = 700; //1 tick surpassed + 100ms ping compensate

   //sleep until isPendingContinuation() == false
   new ConditionalSleep(timeout, sleepTime) {
    @Override
    public boolean condition() throws InterruptedException {
     return !getDialogues().isPendingContinuation();
    }
   }.sleep();

   //release space
   getKeyboard().releaseKey(KeyEvent.VK_SPACE);

  }

 

Yeah you'd think this would work but in the problem is that getKeyboard().pressKey(KeyEvent.VK_SPACE); doesn't actually seems to hold the spacebarm, but only press it once in a dialogue. Overnight I might have came up with a solution though, if you long press a key in the chatbox, it types like 10 characters a second, the same as calling typeKey(' ') 10 times a second would do. I might just simulate that.

  • 3 years later...

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.