Created
June 13, 2019 22:03
-
-
Save mikla/98d3fbe8cd0f332536ea4140509d6afd to your computer and use it in GitHub Desktop.
App that presses keys randomly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.Robot | |
| import java.awt.event.{InputEvent, KeyEvent} | |
| import scala.util._ | |
| object KeyPresser extends App { | |
| import KeyEvent._ | |
| val robot = new Robot() | |
| val keys = Array(VK_A, VK_B, VK_C, VK_D, VK_E, VK_F, VK_G, VK_H, VK_I, VK_J, VK_K, VK_L, VK_M, VK_N, VK_O, VK_P, | |
| VK_Q, VK_R, VK_S, VK_T, VK_U, VK_V, VK_W, VK_X, VK_Y, VK_Z) | |
| val rnd = Random | |
| while (true) { | |
| val keyIndex = rnd.nextInt(keys.length) | |
| val nextKey = keys(keyIndex) | |
| robot.keyPress(nextKey) | |
| robot.keyRelease(nextKey) | |
| Thread.sleep(100) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment