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

Support for stopping other hooks for receiving keystroke notifications #52

Open
c-giannoulis opened this issue Mar 22, 2024 · 1 comment

Comments

@c-giannoulis
Copy link

c-giannoulis commented Mar 22, 2024

It would very useful to implement the return code for the hooks to stop certain keystrokes for monitored keyboards reaching also the standard input.
My use case is that a barcode scanner input get captured but the input also arrives on the System.in InputStream too.
An R/W marker method setHandled(), or stopProcessing() could indicate that the CallNextHookEx() should be bypassed for this iteration.

ref: https://learn.microsoft.com/en-us/windows/win32/winmsg/lowlevelkeyboardproc

If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx.

If nCode is greater than or equal to zero, and the hook procedure did not process the message, it is highly recommended that you call CallNextHookEx and return the value it returns; otherwise, other applications that have installed WH_KEYBOARD_LL hooks will not receive hook notifications and may behave incorrectly as a result.

If the hook procedure processed the message, it may return a nonzero value to prevent the system from passing the message to the rest of the hook chain or the target window procedure.

@kristian
Copy link
Owner

Hey @c-giannoulis, sounds like a good addition. Thanks for providing the reference to the API. Feel free to provide a PR adding this feature. At the moment I don't have the time to work on the project, but I would be happy to review & merge a PR any point in time. Thanks.

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