Jump to content

Instant Keyboard Typer


Recommended Posts

Posted (edited)

I need help finding a keyboard that types instantly. I used one in the past but it doesn't seem to work anymore and I'm not sure what exactly the issue is. It can be found in this thread here:

The solution (which worked in the past) was given by @Explv

 

Thank you.

Edited by glide
Posted
private void typeStringInstant(String output){

    for(int i = 0; i < output.length(); i ++){

        char c = output.charAt(i);
        int code = KeyEvent.getExtendedKeyCodeForChar(c);
        // Type the character
        getBot().getKeyEventHandler().generateBotKeyEvent(400, System.currentTimeMillis(), 0, code, c);
    }

    // Press enter
    getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000', 1);
    // Release enter
    getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000', 1);
}

 

This works almost fine for me. You have to change one thing with the Press enter and release enter. I bet the method generateBotKeyEvent was updated because it shouldn't have the 1 at the end.

Instead it should be getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000');

and getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000');

Of course there is also some natural delay between when the chat is sent and when it appears, but it instantly types and sends the message.

The code I tested this with and worked is here:

 

package net.chatbox.instantchat;

import java.awt.event.KeyEvent;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Helper", info = "Instant Chat", logo = "", name = "Instant Chatter", version = 0)
public class InstantChat extends Script{

	@Override
	public int onLoop() throws InterruptedException {
		return 100;
	}

	public void onStart(){
		typeStringInstant("This probably will work just fine for me");
	}
	
	public void onExit() {
		typeStringInstant("Double-checking this");
	}
	
	private void typeStringInstant(String output)
	{

	    for(int i = 0; i < output.length(); i++)
	    {

	        char c = output.charAt(i);
	        int code = KeyEvent.getExtendedKeyCodeForChar(c);
	        // Type the character
	        getBot().getKeyEventHandler().generateBotKeyEvent(400, System.currentTimeMillis(), 0, code, c);
	    }

	    // Press enter
	    getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000');
	    // Release enter
	    getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000');
	}
	
	
	
	
	
	
	
	
}

 

  • Like 1
Posted
2 hours ago, jakealaka9 said:

private void typeStringInstant(String output){

    for(int i = 0; i < output.length(); i ++){

        char c = output.charAt(i);
        int code = KeyEvent.getExtendedKeyCodeForChar(c);
        // Type the character
        getBot().getKeyEventHandler().generateBotKeyEvent(400, System.currentTimeMillis(), 0, code, c);
    }

    // Press enter
    getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000', 1);
    // Release enter
    getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000', 1);
}

 

This works almost fine for me. You have to change one thing with the Press enter and release enter. I bet the method generateBotKeyEvent was updated because it shouldn't have the 1 at the end.

Instead it should be getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000');

and getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000');

Of course there is also some natural delay between when the chat is sent and when it appears, but it instantly types and sends the message.

The code I tested this with and worked is here:

 


package net.chatbox.instantchat;

import java.awt.event.KeyEvent;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Helper", info = "Instant Chat", logo = "", name = "Instant Chatter", version = 0)
public class InstantChat extends Script{

	@Override
	public int onLoop() throws InterruptedException {
		return 100;
	}

	public void onStart(){
		typeStringInstant("This probably will work just fine for me");
	}
	
	public void onExit() {
		typeStringInstant("Double-checking this");
	}
	
	private void typeStringInstant(String output)
	{

	    for(int i = 0; i < output.length(); i++)
	    {

	        char c = output.charAt(i);
	        int code = KeyEvent.getExtendedKeyCodeForChar(c);
	        // Type the character
	        getBot().getKeyEventHandler().generateBotKeyEvent(400, System.currentTimeMillis(), 0, code, c);
	    }

	    // Press enter
	    getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000');
	    // Release enter
	    getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000');
	}
	
	
	
	
	
	
	
	
}

 

Thank you so much! It works perfectly.

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