Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Mouse Event #4

Open
Yogi09 opened this issue Jun 20, 2019 · 2 comments
Open

Issue with Mouse Event #4

Yogi09 opened this issue Jun 20, 2019 · 2 comments

Comments

@Yogi09
Copy link

Yogi09 commented Jun 20, 2019

Sometimes it is giving below exception , how to solve this

a
org.simplenativehooks.AbstractNativeHookEventProcessor processStdout
WARNING: Exception when processing stdout for Windows Hook. null
java.lang.NullPointerException
at java.util.LinkedList$ListItr.next(LinkedList.java:893)
at org.simplenativehooks.NativeHookGlobalEventPublisher.publishMouseEvent(NativeHookGlobalEventPublisher.java:56)
at org.simplenativehooks.windows.GlobalWindowsEventOchestrator.processStdout(GlobalWindowsEventOchestrator.java:81)
at org.simplenativehooks.AbstractNativeHookEventProcessor.processStdout(AbstractNativeHookEventProcessor.java:142)
at org.simplenativehooks.AbstractNativeHookEventProcessor.access$000(AbstractNativeHookEventProcessor.java:13)
at org.simplenativehooks.AbstractNativeHookEventProcessor$1.run(AbstractNativeHookEventProcessor.java:70)

@hptruong93
Copy link
Contributor

Do you have steps to reproduce this?
Could you post your code here?

@Yogi09
Copy link
Author

Yogi09 commented Jul 3, 2019

It produce some time not always, here is my code for starting and closing hook, code is same which is given in lib. using on windows 10.

public void closeHook() {
try {
NativeHookInitializer.of().stop();

    } catch (Exception ex) {
        System.out.println("Home Design " + ex);
    }
}

public void keyboardPressed() {

    /* Extracting resources */
    try {
        BootStrapResources.extractResources();
    } catch (IOException e) {
        System.out.println("Cannot extract bootstrap resources.");
        e.printStackTrace();
        System.exit(2);
    }
    /* Initializing global hooks */
    NativeHookInitializer.of().start();

    /* Set up callbacks */
    NativeKeyHook key = NativeKeyHook.of();
    key.setKeyPressed(new Function<org.simplenativehooks.events.NativeKeyEvent, Boolean>() {
        @Override
        public Boolean apply(org.simplenativehooks.events.NativeKeyEvent d) {
            str_key_pressed = "Key Released: java "+d.getKey();
            arr_keyboard_pressed.add(str_key_pressed);
            mm = 1;
            return true;
        }
    });
    key.setKeyReleased(new Function<org.simplenativehooks.events.NativeKeyEvent, Boolean>() {
        @Override
        public Boolean apply(org.simplenativehooks.events.NativeKeyEvent d) {
            System.out.println("Key released: " + d.getKey());
            mm=1;
         
            return true;
        }
    });
    key.startListening();

    NativeMouseHook mouse = NativeMouseHook.of();
    mouse.setMousePressed(new Function<org.simplenativehooks.events.NativeMouseEvent, Boolean>() {
        @Override
        public Boolean apply(org.simplenativehooks.events.NativeMouseEvent d) {
            arr_mouse_moved.add(d.toString());
            mm = 1;
            return true;
        }
    });
    mouse.setMouseReleased(new Function<org.simplenativehooks.events.NativeMouseEvent, Boolean>() {
        @Override
        public Boolean apply(org.simplenativehooks.events.NativeMouseEvent d) {
            arr_mouse_moved.add(d.toString());
            mm = 1;
            return true;
        }
    });

    mouse.startListening();

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants