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

Monitoring the input of the barcode scanner may result in partial data loss #466

Open
YiXiXiao opened this issue Jun 25, 2024 · 4 comments

Comments

@YiXiXiao
Copy link

Hi,
When I am using the jcef framework to develop Windows desktop programs, I use jnativehook to listen to the barcode scanner and keyboard input. When I use the barcode scanner to continuously and quickly scan the code, there may be a shortage of execution of the NativeKeyListener callback method. For example, barcode 6901028240410 has a total of 13 digits, but nativeKeyTyped only executes 12 times, resulting in outputs of 6, 9, 0, 1, 2, 8, 2, 4, 0, 4, 1, 0.
My program is as follows:

private void registerScanListener() {
try {
scanLogger.setLevel(java.util.logging.Level.OFF);
GlobalScreen.setEventDispatcher(new SwingDispatchService());
GlobalScreen.registerNativeHook();
}
catch (NativeHookException e) {
e.printStackTrace();
}

    GlobalScreen.addNativeKeyListener(new NativeKeyListener() {
        @Override
        public void nativeKeyTyped(NativeKeyEvent nativeKeyEvent) {
          if (Character.isLetterOrDigit(nativeKeyEvent.getKeyCode())) {
              System.out.println(NativeKeyEvent.getKeyText(nativeKeyEvent.getKeyCode()));
          }
        }

        @Override
        public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) {
            
        }

        @Override
        public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) {

        }
    });
}
@kwhat
Copy link
Owner

kwhat commented Jun 25, 2024

I believe this is resolved in the . 3 relase, but I don't have a build yet.

@kwhat
Copy link
Owner

kwhat commented Jun 25, 2024

If you look at the debug log, do you get a message about restarting the hook?

@YiXiXiao
Copy link
Author

If you look at the debug log, do you get a message about restarting the hook?

I'm very sorry, I haven't found any logs related to hook restart, and this issue may only occur when scanning quickly and continuously.

When will version. 3 be available?

Thank you very much!

@liaoliang
Copy link

liaoliang commented Jul 11, 2024

barcode input type may lose charactor, how to solve

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

3 participants