Change window position

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RonS132

I’m trying to make something similar to desktop goose, so I made a sprite with a transparent background, but I can’t click anything through it. Is there a way I can make the window super small to only contain the sprite, but the window can move? Sorry if this is confusing. Basically, how can I make the window move around in godot 4? Any help would be appricieated!

:bust_in_silhouette: Reply From: crossbito

Hi, I think this is what you’re looking for:

To set the size and position of the game window in Godot, you can use the following code(
I tested the input to confirm that the window moves randomly, and it does.):

if Input.is_action_just_pressed("click"):
		var rand =

		var width = rand.randi_range(0, 1000)
		var height = rand.randi_range(0, 1000)

		get_window().size = Vector2(width, height)
		get_window().position = Vector2(width, width)

In this example, size sets the dimensions of the window to random values (pixels), and position sets the window’s position to random heigth and width on the screen. Please note that the coordinate system may vary depending on your monitor setup. In my case, the code positions the window on the top left corner of the left monitor becouse it’s between 0 and 1000.

I hope this helps!