Guest User

Untitled

a guest
Apr 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 KB | None | 0 0
  1. import java.io.Console;
  2. import java.io.IOException;
  3.  
  4.  
  5. public class RemoteWhatsapp {
  6.     private static final String ADB_SHELL_INPUT_KEYEVENT = "adb shell input keyevent %s";
  7.    
  8.     public static void main(String ... args) throws IOException, InterruptedException {
  9.         Console c = System.console();
  10.         Runtime r = Runtime.getRuntime();
  11.         while(true) {
  12.             char[] cArr = c.readLine().toUpperCase().toCharArray();
  13.             for(char ch : cArr) {
  14.                 Process pr = r.exec(String.format(ADB_SHELL_INPUT_KEYEVENT, getKey(ch)));
  15.                 pr.waitFor();
  16.             }
  17.             Process pr = r.exec(String.format(ADB_SHELL_INPUT_KEYEVENT, 66));
  18.             pr.waitFor();
  19.         }
  20.     }
  21.    
  22.     private static int getKey(char c) {
  23.         int returnValue = 0;
  24.        
  25.         switch(c) {
  26.             case 'A':
  27.                 returnValue = 29;
  28.                 break;
  29.             case 'B':
  30.                 returnValue = 30;
  31.                 break;
  32.             case 'C':
  33.                 returnValue = 31;
  34.                 break;
  35.             case 'D':
  36.                 returnValue = 32;
  37.                 break;
  38.             case 'E':
  39.                 returnValue = 33;
  40.                 break;
  41.             case 'F':
  42.                 returnValue = 34;
  43.                 break;
  44.             case 'G':
  45.                 returnValue = 35;
  46.                 break;
  47.             case 'H':
  48.                 returnValue = 36;
  49.                 break;
  50.             case 'I':
  51.                 returnValue = 37;
  52.                 break;
  53.             case 'J':
  54.                 returnValue = 38;
  55.                 break;
  56.             case 'K':
  57.                 returnValue = 39;
  58.                 break;
  59.             case 'L':
  60.                 returnValue = 40;
  61.                 break;
  62.             case 'M':
  63.                 returnValue = 41;
  64.                 break;
  65.             case 'N':
  66.                 returnValue = 42;
  67.                 break;
  68.             case 'O':
  69.                 returnValue = 43;
  70.                 break;
  71.             case 'P':
  72.                 returnValue = 44;
  73.                 break;
  74.             case 'Q':
  75.                 returnValue = 45;
  76.                 break;
  77.             case 'R':
  78.                 returnValue = 46;
  79.                 break;
  80.             case 'S':
  81.                 returnValue = 47;
  82.                 break;
  83.             case 'T':
  84.                 returnValue = 48;
  85.                 break;
  86.             case 'U':
  87.                 returnValue = 49;
  88.                 break;
  89.             case 'V':
  90.                 returnValue = 50;
  91.                 break;
  92.             case 'W':
  93.                 returnValue = 51;
  94.                 break;
  95.             case 'X':
  96.                 returnValue = 52;
  97.                 break;
  98.             case 'Y':
  99.                 returnValue = 53;
  100.                 break;
  101.             case 'Z':
  102.                 returnValue = 54;
  103.                 break;
  104.             case ' ':
  105.                 returnValue = 62;
  106.                 break;
  107.         }
  108.        
  109.         return returnValue;
  110.     }
  111. }
Add Comment
Please, Sign In to add comment