How to detect when user minimize game?

Hey! After having searched half the internet looking for an answer, I have not found anything that can help me with my problem. I am surprised that there is not so much information about it since I consider that this is something important.

Problem:

I am trying to minimize the game, which by default is in immersive fullscreen, to detect it and lower the frames because they are not necessary. Something like pausing the entire game. I also have the problem that when I “Alt+Tab”, the game overlaps other Windows applications.

I have been reading that a possible solution is detecting with C++ (my project is from Blueprints) it is possible to detect when the user is not in the game. But unfortunately I’m a newbie right now and I don’t understand much about C++ at the moment. So at the point of adding code to the “player controller” in C++ already having a player controller in Blueprint I totally lose myself because I don’t get the knowledge right now. I just want to understand if there is any creative way to solve my problem since I know that auto detection automatic as such is only possible in C++.

Summary: I want to reduce the FPS, pause the game and fix the problem that the game always stays below all the applications that I open in Windows 11 when I minimize the game.

Posible solution:

The only thing I thought was to make the game start in “Fullscreen Window mode” to avoid the overlay problem (I still don’t know how I would solve the other problems) and create a menu with the possibility of giving the user to choose whether to play in “Total Fullscreen Mode” or not. Although I think it is a non-optimal solution.

I hope I have explained myself well. Thank you very much for taking the time to read.

Cheers!

Currently, there is no way to check for minimize, maximize, resize…etc

Currently, not native… To be honest…

But… There is a really cheap plugin, that is exactly doing that:
Viewport Extension Plugin

1 Like

Actually, it’s possible to check whether the window is minimized:

TSharedPtr<SWindow> activeWindow = FSlateApplication::Get().GetActiveTopLevelWindow();
if (activeWindow.IsValid())
{
	bool isMinimized = activeWindow->GetNativeWindow()->IsMinimized());
}

However, isMinimized will only become true if the game is running in “Windowed Mode”. In Borderless Fullscreen, it seems like the only approach is to check whether the window is in focus. Thankfully, there is a great tutorial for checking this and reducing the framerate as appropriate over here:

4 Likes