@SimpleFunction( description = "key event code input")
public void KeyEventEscape() {
Instrumentation inst = new Instrumentation();
try {
Field field = KeyEvent.class.getField("KEYCODE_ANY_HERE");
int value = (int) field.get(null); // its a static reference
inst.sendKeyDownUpSync(value);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
// do not merge, java 6+
throw new RuntimeException(e);
}
}
@SimpleFunction( description = "key event code input")
public void KeyEventEscape() {
final int value;
try {
Field field = KeyEvent.class.getField("KEYCODE_ANY_HERE");
value = (int) field.get(null); // its a static reference
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
// do not merge, java 6+
throw new RuntimeException(e);
}
new Thread(new Runnable() {
@Override
public void run() {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(value);
}
}).start();
}