Stay Awake

Post your working scripts, libraries and tools.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Stay Awake

Post by jNizM » 21 Oct 2021, 08:46

Stay Awake
Stay Awake is a utility tool for Windows designed to keep a computer awake without having to manage its power & sleep settings.


Source
stay-awake (GitHub)


Download (precompiled executable)
Image


Examples
Image


Features
- Off (Passive) - The computer awakeness state is unaffected. The application is waiting for user input.
- Keep awake indefinitely - The computer stays awake indefinitely, until the user explicitly puts the machine to sleep or exits/disables the application.
- Keep awake temporarily - Keep machine awake for a pre-defined limited time. Once the time elapses, computer resumes its previous awakeness state.
- Keep screen on - While Awake can keep the computer awake indefinitely or temporarily, in its default state the displays connected to the machine will turn off, even though the computer won't go to sleep. If you need the displays to be available, use the Keep screen on switch, which will ensure that all monitors remain on.
- System tray - manage the execution of the tool from the system tray, right-click on the tray-icon.
- Settings Gui - manage the awakeness state of the computer.


Test environment
Image Image


Contributing
- thanks to AutoHotkey Community


Inspired by
- Awake utility from PowerToys


Questions / Bugs / Issues
If you notice any kind of bugs or issues, report them here. Same for any kind of questions.


Copyright and License
Image
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Stay Awake

Post by jNizM » 21 Oct 2021, 08:46

Todo
- Fix bugs
- Optimize code
- Whatever


Changelog

Code: Select all

2021-11-16 Added a kind of dark mode
2021-11-16 Changed run-loop from 30 to 60 seconds
2021-10-22 Changed SetTimer / Changed Gui / Cleanup Code
2021-10-21 Initial
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Stay Awake

Post by joedf » 21 Oct 2021, 12:06

Love your work as always! very neat :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Stay Awake

Post by AHK_user » 21 Oct 2021, 12:57

Clean code :clap:

One tip that is maybe interesting:
There is a simple alternative way to create colored rectangles in the gui: You can use empty text controls with a background color.
This requires less code.

Code: Select all

hFBFBFB := DllCall("gdi32\CreateBitmap", "int", 1, "int", 1, "uint", 0x1, "uint", 32, "int64*", 0xfbfbfb, "ptr")
Main.AddPicture("xs+1 ys+9 w350 h50 BackgroundTrans", "HBITMAP:*" hFBFBFB)
Can be replaced by:

Code: Select all

Main.AddText("xs+1 ys+9 w350 h50 Background0xfbfbfb")
You could also use this trick to replace the GroupBox. The advantage is that the coordinates are a little bit easier to predict and you can set any color.

Of course the DllCall is also quite interesting, as you can do a lot of other things with it.

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Stay Awake

Post by jNizM » 22 Oct 2021, 04:01

@joedf
thank you ;)


@AHK_user
thank you ;)
I know. I could also use Progressbars to archiv this or gdip, but I have consciously decided to use a Bitmap.
I also removed GroupBox now and used a 2nd Bitmap layer to get the grey border.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Stay Awake

Post by jNizM » 16 Nov 2021, 04:47

Changes:
- Added a kind of dark mode (feel free to test it and suggestions for better colors)
- Changed run-loop from 30 to 60 seconds (windows 10/11 minimum power saving mode)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

invalid-origin
Posts: 2
Joined: 13 Jun 2022, 09:33

Re: Stay Awake

Post by invalid-origin » 13 Jun 2022, 09:51

I installed this today and noticed that it does not keep Microsoft Teams from showing away. Would it be possible to incorporate this function?

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Stay Awake

Post by jNizM » 14 Jun 2022, 03:05

This tool is designed to keep a computer awake. Not an application.

But you will surely find something about your problem here in the forum.
Alternatively, you can also ask this in the Ask to Help section (viewforum.php?f=76)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

Post Reply

Return to “Scripts and Functions (v2)”