imJordanB Posted November 1, 2015 Share Posted November 1, 2015 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 Quote Link to comment Share on other sites More sharing options...
Wishy Posted November 1, 2015 Share Posted November 1, 2015 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. Quote Link to comment Share on other sites More sharing options...
imJordanB Posted November 1, 2015 Author Share Posted November 1, 2015 Wouldnt you change something like the sleeping condition? Lower the time before it re-starts that part. The sleeping condition won't affect how fast the keys are pressed Quote Link to comment Share on other sites More sharing options...
Chicken Wing Posted November 1, 2015 Share Posted November 1, 2015 http://osbot.org/forum/topic/73829-smartkeyboard-better-human-typing/ I think this might help Quote Link to comment Share on other sites More sharing options...
imJordanB Posted November 1, 2015 Author Share Posted November 1, 2015 http://osbot.org/forum/topic/73829-smartkeyboard-better-human-typing/ I think this might help 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 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted November 1, 2015 Share Posted November 1, 2015 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 Someone had the source for an instant typer once upon a time, not sure how it was done but try looking into KeyEvents? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted November 3, 2015 Share Posted November 3, 2015 (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 November 3, 2015 by FrostBug Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted November 4, 2015 Share Posted November 4, 2015 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); Quote Link to comment Share on other sites More sharing options...
FrostBug Posted November 5, 2015 Share Posted November 5, 2015 (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 November 5, 2015 by FrostBug Quote Link to comment Share on other sites More sharing options...
Explv Posted November 7, 2015 Share Posted November 7, 2015 (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 November 7, 2015 by Explv Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted November 7, 2015 Share Posted November 7, 2015 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). Quote Link to comment Share on other sites More sharing options...
Explv Posted November 7, 2015 Share Posted November 7, 2015 (edited) 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). Oops didn't even notice. Corrected my post, thanks for pointing it out. Edited November 7, 2015 by Explv Quote Link to comment Share on other sites More sharing options...