Advertisement
Guest User

Untitled

a guest
Jan 29th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.KeyEvent;
  5.  
  6. public class Main {
  7.  
  8.     static class KeyController {
  9.         Robot robot;
  10.         KeyController() throws AWTException, InterruptedException {
  11.             robot = new Robot();
  12.             System.out.println("starting in 10 seconds..");
  13.             Thread.sleep(10000);
  14.  
  15.         }
  16.  
  17.         void pressKey(int key) throws InterruptedException {
  18.  
  19.             Thread.sleep(20);
  20.             robot.keyPress(key);
  21.             Thread.sleep(20);
  22.             robot.keyRelease(key);
  23.         }
  24.  
  25.         void pressNum(int... num) throws InterruptedException {
  26.            
  27.  
  28.             for(int i = 0; i<num.length; i++) {
  29.  
  30.  
  31.                 switch (num[i]) {
  32.                     case 1: pressKey(KeyEvent.VK_1);
  33.                         break;
  34.                     case 2: pressKey(KeyEvent.VK_2);
  35.                         break;
  36.                     case 3: pressKey(KeyEvent.VK_3);
  37.                         break;
  38.                     case 4: pressKey(KeyEvent.VK_4);
  39.                         break;
  40.                 }
  41.  
  42.             }
  43.  
  44.  
  45.         }
  46.     }
  47.  
  48.     public static void main(String[] args) throws AWTException, InterruptedException {
  49.  
  50.  
  51.         KeyController keyController = new KeyController();
  52.  
  53.  
  54.         int[] turnOne = {2,3,4};
  55.         int[] turnTwo = {1,2,3,4};
  56.         int[] turnThree ={1,2,3,4};
  57.         int[] turnFour = {1,2,3,4};
  58.         int[] turnFive = {1};
  59.         int[] turnSix = {1};
  60.  
  61.  
  62.         for (int one:turnOne)
  63.             for(int two:turnTwo)
  64.                 for(int three:turnThree)
  65.                     for(int four:turnFour)
  66.                         for(int five:turnFive)
  67.                             for(int six:turnSix){
  68.                                 System.out.println("Attempthing: ");
  69.                               int[] combination = {one,two,three,four,five,six};
  70.                                 for(int i:combination) {
  71.                                     keyController.pressNum(i);
  72.                                     System.out.print(i+", ");
  73.                                 }
  74.                             }
  75.  
  76.  
  77.     }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement