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

The raw mode causes my application interface (Swing/JavaFX) to not recieve the events. #17

Open
mwss1996 opened this issue Jun 11, 2017 · 11 comments
Labels

Comments

@mwss1996
Copy link

If I instantiate the GlobalKeyboardHook, with a true parameter, my application stops to recieve the key events. The same with GlobalMouseHook, but for mouse events.

I am writing a Swing application, but I have tested the issue with JavaFX to confirm if it was not a Swing specifc problem.

As example, the below JavaFX application becomes unusable:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import lc.kra.system.keyboard.GlobalKeyboardHook;
import lc.kra.system.mouse.GlobalMouseHook;

public class Test extends Application {

	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage primaryStage) throws Exception {

		GlobalMouseHook mouseHook = new GlobalMouseHook(true);
		GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(true);

		TextField textField = new TextField();
		HBox hBox = new HBox();
		hBox.getChildren().add(textField);
		Scene scene = new Scene(hBox);
		primaryStage.setScene(scene);
		primaryStage.show();
	}
}
@kristian kristian added the bug label Jun 11, 2017
@kristian
Copy link
Owner

Interesting. No idea why this happens yet... According to the Windows documentation raw input should be a plain "listener". Blocking inputs isn't possible. Strange...

@mwss1996
Copy link
Author

hope you can figure it out. I have no ideia.

@mdloucks
Copy link

I've been having the same problem with JavaFX text fields, the problem fixes itself once the parameter is changed to 'false', but I hope you can fix the problem!

@kristian
Copy link
Owner

If raw input is not required, the it's fine to leave the parameter remain false. I can reproduce the problem for both JavaFX and Swing/AWT. Seems strange to me... I hope Java doesn't register a raw input hook itself, otherwise it might runs into problem, as both share the same process ID to register the window handle... Just a wild guess. I hope I can look into this tomorrow.

@sirgyula
Copy link

sirgyula commented Aug 15, 2017

Hello kristian!
This problem occurred here too. Have you found any reason for the bug? Do you know any drawback using the hook with raw=false?
I'm using win10 prof 1703 and java1.8_144 with JavaFx, if that helps.
Thanks!

@Fish-In-A-Suit
Copy link

I have been using the SYS in combination with LWJGL api (for the rendering part of my application), and have faced the same issue, where the window just froze when trying to collect input with raw mode. Switching from true to false in the constructor for GlobalMouseHook resolved the issue.

@jjYBdx4IL
Copy link

Apparently, it's possible to register hotkey without window resources: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registerhotkey The hwnd parameter is optional. Maybe that helps. If you need the window resource for some reason, maybe add a default mode that is not using it, and an extended mode that can be activated by the user but tells him it may not work.

@leopoldhub
Copy link

same problem for me... please fix it ;-;

@Zh-Can
Copy link

Zh-Can commented Aug 20, 2020

I've been having the same problem ....

@KOConchobhair
Copy link

Hello @kristian just stumbled across your library and this issue...could it perhaps be related to not calling DefRawInputProc(&input, 1, sizeof(RAWINPUTHEADER)); after GetRawInputData(...)?

See the post here where the author states,

Finally, we call Def­Raw­Input­Proc to allow default processing to occur. This lets the keypress enter the normal input system.

@kristian
Copy link
Owner

kristian commented Oct 18, 2020

Good catch @KOConchobhair and would fit the issue quite well. Unfortunately no success on my side... I added it anyways in c946389 / 3.8, as I think it's good to have it in. The issue w/ Java is still not solved though... Shame.

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

No branches or pull requests

9 participants