Jump to content

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


imJordanB

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

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);
Link to comment
Share on other sites

 

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...