Windows Any way to disable a player's screensaver in GM2 for Windows Game Builds? [SOLVED]

otterZ

Member
Is there any way to disable the player's screensaver if they are using a Windows operating system to play my game?

The game I'm making runs up to 40 minutes without the player having to move the mouse or push a single key, but if their screensaver is enabled for under 40 mins the screensaver will interrupt the game.

Ideally, I'd like to stop the screensaver whilst the game is being played but be enabled back to normal when they close the game down.

I did a search on the internet and found this article, which had this to say:

'Disable screensavers and power saving actions
When checked (default) screensavers or power saving actions (sleep, hibernate) will not activate while the game is running. This is important as these might destroy certain graphics aspects of the game (like surfaces).'

This is meant to be in the graphics options for games made - but I could not find this option in GM2.

Perhaps this was an option in the original Gamemaker but not in GM2? Perhaps it was taken out because it is now frowned upon to control a player's screensaver?

If it is seen as ethically wrong to suspend someone's screensaver I could always put in the game's info/manual that screensavers should be disabled or set to more than 40 mins.
 
I don't know if this action would be registered by Windows to reset the screensaver timer, but assuming the mouse doesn't need to be absolutely still for the duration of the game, you could try moving the mouse via code every 5 minutes or so.
 

otterZ

Member
I don't know if this action would be registered by Windows to reset the screensaver timer, but assuming the mouse doesn't need to be absolutely still for the duration of the game, you could try moving the mouse via code every 5 minutes or so.
Thanks BattleRifle BR55, that's an interesting idea - I will look into this. Just waiting for a Windows desktop computer to be delivered as I'm switching from a Mac to Windows. Then I'll test this idea out.
 

Alexx

Member
Depending on why you want to keep the game running, there are a few other approaches available.

For example, if it's something like a counter, you could save the date and time to an INI file every minute, then calculate the difference when the game restarts / gets focus.

Some more info would be helpful.
 

otterZ

Member
Depending on why you want to keep the game running, there are a few other approaches available.

For example, if it's something like a counter, you could save the date and time to an INI file every minute, then calculate the difference when the game restarts / gets focus.

Some more info would be helpful.
Thanks Alexx, that is a good option, and yes there is a running counter in the game, so that's ideal.
You asked for more info - the game is an exercise game where the player exercises along to an animated sprite. If you click on the link to 'Games in Progress' below it's the one called 'Boot Camp Fitness'. It will take you to a video where you can see it in action. It's basically an option to workout at home not needing VR equipment. The longest workout time you can choose is 40 minutes long - this is where I'm having to think about if the player has their screensaver enabled for less than that time.
Your idea is really interesting because there is a workout timer running alongside each workout, where I could save information to an INI file if that would do the trick. I appreciate your advice.
 

Alexx

Member
I think that @BattleRifle BR55
idea may be more suitable for your needs.

I suggest making a new project, simulate a mouse movement or click every 5 minutes, and set your screensaver to 10 minutes.
I'd be interested in knowing whether this works, not something I've ever tried.

I'm stuck inside for a few months, so hope this project takes off - would be nice to have something else to do...
 

otterZ

Member
[QUOTE="

I suggest making a new project, simulate a mouse movement or click every 5 minutes, and set your screensaver to 10 minutes . . .
[/QUOTE]
Thanks Alexx, yeah that's something I've added to my game improvement list to do as I like this idea- just frantically adding exercise variations/animations at present for players to have even more exercise variations. I like the idea of making a separate project and stripping it down to just testing whether this works effectively or not.
BTW - Your ebook range looks a great way to help beginners hit the ground running and have fun using GM2.
 
Testing things in a standalone project is a great way to experiment and play around with things. I do it -all- the time. Let's you clear your head, figure out where problems lie, organise the code flow and everything without polluting your project with dead ends and extraneous code. When you then do implement it in your main project, you've almost always found ways to optimise your approach and make things flow smoother, leading to your main project needing less refactoring, which removes a huge pain in the arse.
 

otterZ

Member
Testing things in a standalone project is a great way to experiment and play around with things. I do it -all- the time. Let's you clear your head, figure out where problems lie, organise the code flow and everything without polluting your project with dead ends and extraneous code. When you then do implement it in your main project, you've almost always found ways to optimise your approach and make things flow smoother, leading to your main project needing less refactoring, which removes a huge pain in the arse.
I agree RefresherTowel, I put in quite a complex algorithm system that was at first overwhelming, so made a separate project with different coloured blocks on a lot smaller level. So nice not having to build the main game every time you want to test it too.
Yeah, it's nice to clear your head as you said, stepping away from the main project to focus on one particular thing, almost like in a virtual lab.
One thing I really enjoy doing is building a 'testing' object where it displays variable states, the names of instances being called or guidelines to place sprites etc. When I get stuck on a bug I can't see I just pop the testing object into that room and it sometimes points out the problem for me. I'm sure more experienced coders do this as just part of the process but as a beginner to elementary level coder (1 year on GM) these tips, like your tip for testing elements of a game routinely in mini test projects is really helpful.
 
FYI, I tried Alexx's "simulated click" method by using the keyboard_key_press function in an alarm (I couldn't find a mouse click equivalent in the documentation, although I'm sure there is one), and it DOES work, just so long as you assign a key that isn't otherwise used in your game. This was something I was wondering about, too, because my game has turn based battles, and a lot of time can pass between the player's turns. So thanks to OtterZ for asking the question, and thanks to everyone that answered!
 

otterZ

Member
FYI, I tried Alexx's "simulated click" method by using the keyboard_key_press function in an alarm (I couldn't find a mouse click equivalent in the documentation, although I'm sure there is one), and it DOES work, just so long as you assign a key that isn't otherwise used in your game. This was something I was wondering about, too, because my game has turn based battles, and a lot of time can pass between the player's turns. So thanks to OtterZ for asking the question, and thanks to everyone that answered!
Oh great! Thank you for sharing the result of your experiment and that it works, and good to hear that it is useful in your turn-based game too. I will do the same thing in my game also. Thanks everyone, I will mark this thread as happily 'solved'.
 

Alexx

Member
FYI, I tried Alexx's "simulated click" method by using the keyboard_key_press function in an alarm (I couldn't find a mouse click equivalent in the documentation, although I'm sure there is one), and it DOES work, just so long as you assign a key that isn't otherwise used in your game. This was something I was wondering about, too, because my game has turn based battles, and a lot of time can pass between the player's turns. So thanks to OtterZ for asking the question, and thanks to everyone that answered!
Great to know it works!!
@otterZ
If it is seen as ethically wrong to suspend someone's screensaver I could always put in the game's info/manual that screensavers should be disabled or set to more than 40 mins.
Hmm... possibly.
If I was playing on a tablet or phone. got distracted and came back an hour later to find my battery dead because of this feature, I would be a tad annoyed.
Maybe mention this at game start, and provide an option to be disabled?
 

otterZ

Member
Alexx, I agree, yeah it could even be provided as an option to be disabled, thereby giving the player control which is always good.
Your idea worked which is great!
 
Top