Jump to content

Finished my new script, but how do I type faster?


Recommended Posts

Posted

Hello!

 

I've been working hard on learning how to use OSBot and i've just finished my latest script, HOWEVER, I am using getKeyboard().typeString and realised how slow it types. I am looking for something that types a lot faster, and was wondering how I would make it type a lot faster than it currently does (which isn't fast at all).

 

ANY help is appreciated as always, and I thank you for helping me learn Java and the OSBot api

Posted

Hello!

I've been working hard on learning how to use OSBot and i've just finished my latest script, HOWEVER, I am using getKeyboard().typeString and realised how slow it types. I am looking for something that types a lot faster, and was wondering how I would make it type a lot faster than it currently does (which isn't fast at all).

ANY help is appreciated as always, and I thank you for helping me learn Java and the OSBot api

Wouldnt you change something like the sleeping condition? Lower the time before it re-starts that part.

Posted

 

Thanks for the idea. I will have a look at it, however, I doubt this is going to make it type fast, this is more making the typing look human (by making mistakes), I don't want mistakes in mine, I want it to type really fast (almost instant), as this is going to be ran on trash accounts so I don't care about how human-like it looks :)

Posted

Thanks for the idea. I will have a look at it, however, I doubt this is going to make it type fast, this is more making the typing look human (by making mistakes), I don't want mistakes in mine, I want it to type really fast (almost instant), as this is going to be ran on trash accounts so I don't care about how human-like it looks smile.png

 

Someone had the source for an instant typer once upon a time, not sure how it was done but try looking into KeyEvents?

Posted (edited)

Try something like this? (This is probably what typeString does, but with a substantial delay between each key)

void typeFast(String str) {
    for(char c : str.toCharArray()) {
        getKeyboard().typeKey(c);
    }
    getKeyboard().typeKey((char)KeyEvent.VK_ENTER);
}
Edited by FrostBug
Posted

 

Try something like this? (This is probably what typeString does, but with a substantial delay between each key)

void typeFast(String str) {
    for(char c : str.toCharArray()) {
        getKeyboard().typeKey(c);
    }
    getKeyboard().typeKey((char)KeyEvent.VK_ENTER);
}

 

typeKey() still has the delay afaik (hence why my SmartKeyboard is still pretty slow).

Also, when pressing enter, you want to send 13 & 10 in rapid succession (\r\n):

getKeyboard().typeKey((char)13);
getKeyboard().typeKey((char)10);
Posted (edited)

 

typeKey() still has the delay afaik (hence why my SmartKeyboard is still pretty slow).

Also, when pressing enter, you want to send 13 & 10 in rapid succession (\r\n):

getKeyboard().typeKey((char)13);
getKeyboard().typeKey((char)10);

 

if typekey has a delay, just simulate it instead

getKeyboard().pressKey(c);
getKeyboard().releaseKey(c);

I'll assume typekey does the same, but with a delay inbetween the two

 

Also, do you have a source for the \r\n thing? I really kind of doubt it's necessary. What reason would the game applet have to not simply listen for the VK_ENTER keypress? That's all the actual keyboard key triggers.

 

Edited by FrostBug
Posted (edited)

if typekey has a delay, just simulate it instead

getKeyboard().pressKey(c);
getKeyboard().releaseKey(c);

I'll assume typekey does the same, but with a delay inbetween the two

 

Also, do you have a source for the \r\n thing? I really kind of doubt it's necessary. What reason would the game applet have to not simply listen for the VK_ENTER keypress? That's all the actual keyboard key triggers.

 

For some reason

getKeyboard().pressKey(c);
getKeyboard().releaseKey(c);

Does not work for me (maybe I am doing something wrong)

 

However this does:

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

Edit: GIF demonstration: https://gyazo.com/36757b8e49c1abbcc4b0a4090bb6322e

 

Edited by Explv
Posted

For some reason

getKeyboard().pressKey(c);
getKeyboard().releaseKey(c);

Does not work for me (maybe I am doing something wrong)

 

However this does:

private void typeStringInstant(String output){

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

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

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

Edit: GIF demonstration: https://gyazo.com/36757b8e49c1abbcc4b0a4090bb6322e

You might want to generate a release key event as well (See TypeKeyEvent, which also acquires exclusive access to the KeyEventHandler, that could be a good idea as well). 

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