Is there a way to prevent focus loss?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SupToasty
:warning: Old Version Published before Godot 3 was released.

If I use ALT + Tab or Minimize the window can I make it immediately pop-up again?
I basically want the window to always be on top and always be full-screen, until a quit request is entered.

is that OS authority?
it looks like virus to me, if possible.
I made a game runs with fullscreen, and can’t be changed another window or minimize it.
what if it can not be quit for some reason, like I forget to handle quitting or game has bug with quitting?

volzhs | 2016-06-12 06:08

@volzhs it is for my method of anti-piracy, which I ironically stole from the creators of game dev tycoon. I have a sound file of vuvuzelas on loop and an anoying animation on loop as well. The plan is to make fake versions of my own game and distribute them on sharing sites all through the week of its release. Everything is pirated eventually, working on a drm or authentification system would be pointless, so I figured I should have some fun messing with people who intend to steel my work, before people actually put my game on sharing sites.

SupToasty | 2016-06-12 19:52

:bust_in_silhouette: Reply From: Damyan

func _ready():
OS.set_window_always_on_top (true)
get_tree().set_script(load(“res://listen_to_focus_changes.gd”))

script called listen_to_focus_changes

extends SceneTree
func _notification(what):
match what:
NOTIFICATION_WM_FOCUS_OUT:
OS.set_window_minimized(false)

Please use the

code_syntax

by typing a line break and then four spaces before entering your code.
All your underscores are unreadable and being converted to italic text.

Shaqpower3 | 2021-06-09 14:59