0 votes

I would like to make an application that is more or less a visualizer that responds to key pressed, but for that to work it can't be in focus (specifically as a windows exe).

Is there a way to have Godot register user input while the window is not in focus?

Thanks!

in Engine by (56 points)

1 Answer

+1 vote
Best answer

If you mean have it accept input while another non-Godot application is focused, then no. Your OS's window manager handles focus, applications like Godot can only request focus and request to be unfocused, and no well-written window manager would allow this behavior.

Not only would it be a huge security risk (any program could be a keylogger), but it's also annoying to users, and may cause unnecessary bug reports. A user might wonder why a certain program isn't accepting their input and file a bug report for that application, but it's a completely different application grabbing their input. If you have several of these, you may have to reboot to regain control of your system, as each would randomly grab inputs depending on whether they were active or not, so quitting them may be difficult, especially if you're not aware of what's going on behind the scenes.

A way around this is to run a program from within another program (this is what debuggers and stack tracers do) in which case the parent accepts the input and transfers it to the child program. However, Godot is only capable of asking the OS to start a non-Godot program, the program runs independently of Godot, so you can't intercept input this way, either. In fact, the only inter-process communication (IPC) that I know Godot uses is when it's communicating to a running game, so you can change things in the editor as the game runs.

by (84 points)
selected by

Gamepad input seems to still go to my game while the editor is focused, at least (but definitely not keyboard input).

I hit this topic while searching for the same thing. The answer doesn't seem to make sense since there are many programs that accept hotkey presses outside of focus, like OBS. But if Godot can't do that, then ok.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.