Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package my.pack;
- import java.awt.AWTException;
- import java.awt.Robot;
- import java.awt.event.KeyEvent;
- import java.util.function.Consumer;
- import org.jnativehook.GlobalScreen;
- import org.jnativehook.NativeHookException;
- import org.jnativehook.keyboard.NativeKeyEvent;
- import org.jnativehook.keyboard.NativeKeyListener;
- public class PrintOut {
- static volatile boolean stop = false;
- static volatile String key;
- public static void main(String[] args) {
- try {
- GlobalScreen.registerNativeHook();
- } catch (NativeHookException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- NativeKeyListener listener = new NativeKeyListener() {
- @Override
- public void nativeKeyTyped(NativeKeyEvent arg0) {
- }
- @Override
- public void nativeKeyReleased(NativeKeyEvent arg0) {
- }
- @Override
- public void nativeKeyPressed(NativeKeyEvent arg0) {
- if (arg0.getKeyCode() == 3658) {
- stop = true;
- try {
- Robot robot = new Robot();
- robot.setAutoDelay(1);
- System.out.println(KeyEvent.VK_0);
- Consumer<Integer> press = x -> {
- robot.keyPress(0x30 + x);
- robot.keyRelease(0x30 + x);
- };
- // a b c d
- for (int a = 0; a <= 0; a++) {
- for (int b = 0; b <= 9; b++) {
- for (int c = 0; c <= 9; c++) {
- for (int d = 0; d <= 9; d++) {
- if (a == 0) {
- if (b == 0) {
- if (c == 0) {
- press.accept(d);
- }
- else {
- press.accept(c);
- press.accept(d);
- }
- }
- else {
- press.accept(b);
- press.accept(c);
- press.accept(d);
- }
- }
- else {
- press.accept(a);
- press.accept(b);
- press.accept(c);
- press.accept(d);
- }
- press.accept(KeyEvent.VK_ENTER - 0x30);
- }
- }
- }
- }
- System.exit(0);
- } catch (AWTException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- };
- GlobalScreen.addNativeKeyListener(listener);
- }
- }
Add Comment
Please, Sign In to add comment