How to keep a window always on top ?

WanSou

Member
Heyo, im trying to make an "indicator" for games
And to do that, i need to make the game instance to stay on top of other windows
The same exact thing that is used for example in task manager, when u go to the task manager > settings (top left corner) > always on top it just stays on top, even if you click something in the background
that's exactly what i am trying to do, so if anyone has any ideas on how to do it, i would appreciate it!
 

flyinian

Member
Heyo, im trying to make an "indicator" for games
And to do that, i need to make the game instance to stay on top of other windows
The same exact thing that is used for example in task manager, when u go to the task manager > settings (top left corner) > always on top it just stays on top, even if you click something in the background
that's exactly what i am trying to do, so if anyone has any ideas on how to do it, i would appreciate it!
You could draw what you need in the gui draw event. That draws over everything in the regular draw event. Then control the instance's depth through code. 'depth' in the create/step even.

You could also just use the depth system. In an object that you want it to draw over everything just add 'depth' to the create/step event and assign it the desired layer. The room management also has a depth layer system.
0 = mid layer, negative values = higher layer, positive values = deeper layer.

Here is the GMS2 manual on depth.
 

WanSou

Member
You could draw what you need in the gui draw event. That draws over everything in the regular draw event. Then control the instance's depth through code. 'depth' in the create/step even.

You could also just use the depth system. In an object that you want it to draw over everything just add 'depth' to the create/step event and assign it the desired layer. The room management also has a depth layer system.
0 = mid layer, negative values = higher layer, positive values = deeper layer.

Here is the GMS2 manual on depth.
Hey um... i think you mis-understood
i don't mean layers/depth i mean like the actual game window being ontop of other windows
not in the actual game, but outside it, the actual game window
if you do the example with the task manager that i provided in the post, i think that u will understand a lil bit more on what i mean...
 

flyinian

Member
Hey um... i think you mis-understood
i don't mean layers/depth i mean like the actual game window being ontop of other windows
not in the actual game, but outside it, the actual game window
if you do the example with the task manager that i provided in the post, i think that u will understand a lil bit more on what i mean...
Looks like I did Misunderstood you. My apologizes. with that, I don't know anything about your question. But, if you ever come across depth/layer issues you might have your answer. :)
 

Roldy

Member
You will most likely need an extension for this. Check the marketplace.

For windows you would need to change the window style. You can do this with external programs (AHK, turbo top etc..) but if you want you game to be self contained you will probably need a simple dll as an extension. For other platforms (macOS) you would need additional extensions.

Others might know a different way. If you ask one of the folks here that do extensions on the market place they could probably make you one, especially if you paid them.

I used to have a program that I could force any window to remain on top, but I can't find the code for it. It was like 4 lines of C#, its pretty easy. You could also look into autohotkey for a quick solution, I know it can force any window to stay on top, but it wouldn't be something you would distribute.

EDIT: Unsure what you mean by 'indicator' but you may look into something like this: https://marketplace.yoyogames.com/assets/5105/window-flash-notification
Or some extension to send windows notifications to the notification center.
 
Last edited:
Top