Ayylmao420 Posted April 18, 2017 Posted April 18, 2017 public void typeString(final String string) throws InterruptedException { for (Character character : string.toCharArray()) { getBot().getKeyEventHandler().generateBotKeyEvent(KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, KeyEvent.getExtendedKeyCodeForChar(character), character); sleep(random(50, 100)); getBot().getKeyEventHandler().generateBotKeyEvent(KeyEvent.KEY_RELEASED, System.currentTimeMillis(), 0, KeyEvent.getExtendedKeyCodeForChar(character), character); } } So i came up with this but doesn't work, could someone help me out ?
Juggles Posted April 18, 2017 Posted April 18, 2017 getKeyboard().pressKey(KeyEvent.VK_PAGE_UP); getKeyboard().pressRelease(KeyEvent.VK_PAGE_UP);
Ayylmao420 Posted April 18, 2017 Author Posted April 18, 2017 (edited) 15 hours ago, Juggles said: getKeyboard().pressKey(KeyEvent.VK_PAGE_UP); getKeyboard().pressRelease(KeyEvent.VK_PAGE_UP); for (Character character : string.toCharArray()) { getKeyboard().pressKey(KeyEvent.getExtendedKeyCodeForChar(character)); sleep(random(50, 100)); getKeyboard().releaseKey(KeyEvent.getExtendedKeyCodeForChar(character)); } Doesn't seem to work either, am i doing something wrong ? @Alek Edited April 19, 2017 by Ayylmao420
Ayylmao420 Posted April 19, 2017 Author Posted April 19, 2017 55 minutes ago, Alek said: Keyboard typeString(String string) I wan't to have more control over typing, could you explain me why generateBotKeyEvent doesn't work in my case ?
Alek Posted April 19, 2017 Posted April 19, 2017 Just now, Ayylmao420 said: I wan't to have more control over typing, could you explain me why generateBotKeyEvent doesn't work in my case ? It does what you want, it types a string. If you don't want to use the front API then you should really know how the back API works. 1