Skip to content

Commit 5b8a1af

Browse files
committed
merge branch 'develop'
2 parents 6de8a38 + 42f474a commit 5b8a1af

File tree

14 files changed

+167
-99
lines changed

14 files changed

+167
-99
lines changed

awake.pyw

Lines changed: 0 additions & 77 deletions
This file was deleted.

icon/22.png

-561 Bytes
Binary file not shown.

icon/Z.ico

-5.3 KB
Binary file not shown.

readme.md

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,52 @@
1-
# "Stay Awake, Don't Sleep!" utility (in Python) ![](icon/22.png)
1+
# awake
2+
prevent the system from entering sleep or turning off the display
23

3-
## Background
4-
"Stay Awake, Don't Sleep!" is a small Python utility designed to keep a machine/workstation from going idle. Leveraging the awesome PyAutoGUI library to impersonate a human being and programmatically control the keyboard, this utility presses the scroll lock key ~2 times a second.
4+
- [Background and Information](#background-and-information)
5+
- [Usage](#usage)
6+
- [Development](#development)
7+
- [Python venv and pip](#python-venv-and-pip)
8+
- [Compile](#compile)
9+
- [Further Reading](#further-reading)
10+
- [Useful Links](#useful-links)
511

6-
I built this tool to solve a problem, learn about ```tkinter```, ```pyautogui``` and python ```threading```. Displaying a basic GUI while a second thread takes care of the automation. Interestingly I always press the scroll lock key twice, this means if you started the utility, came back to your machine 30 minutes later and closes it, the "even" number of presses means your scroll lock "state" would be the same as before you left!
12+
## Background and Information
13+
This simple windows app keeps a machine/workstation from going idle. Oriignally this application pressed the Scroll Lock button twice every second to keep windows "awake". The recent version now uses a native windows call "```ES_DISPLAY_REQUIRED```" to keep the display on instead.
14+
15+
I built this tool to solve a problem, learn about ```tkinter```, ```pyautogui``` and python ```threading```. Displaying a basic GUI while a second thread takes care of the automation. You can still see that code in as recent as the [v0.4.0](https://github.com/adambonneruk/awake/tree/v0.4.0) tag.
716

817
## Usage
9-
The App starts in the system tray (with the ![Z](icon/22.png) icon).
18+
The App starts in the system tray (with the [Z] icon).
1019

1120
![Running in the Windows 10 System Tray](.screenshot/in-the-tray.png)
1221

1322
A right-click context menu allowing you to "```Show```" the main GUI (below) or "```Quit```" and close the application. The GUI close cross again minimises to the system tray.
1423

1524
![Running awake.pyw on Windows 10](.screenshot/stay-awake-dont-sleep.png)
1625

17-
What you would want to use this application for? I have no idea!
18-
19-
## Install Guide (using _chololatey_ and _pip_)
20-
Python, PIP, PyAutoGUI, and PyStray
21-
```powershell
22-
# install python using chocolatey
23-
choco install python -y
24-
# install pip using python
25-
python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip
26-
# install pyautogui using pip
27-
python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pyautogui
28-
# install pylance using pip
29-
python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pystray
30-
# run awake.pyw
31-
py ./awake.pyw
26+
## Development
27+
28+
### Python venv and pip
29+
```ps
30+
# create a venv named venv
31+
py -m venv venv
32+
33+
# run venv
34+
venv/Scripts/Activate.ps1
35+
36+
# install pip prereqs
37+
py -m pip install -r .\requirements.txt --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org
38+
```
39+
40+
### Compile
41+
```ps
42+
# run manually
43+
pyinstaller "src/awake.spec" --noconfirm
44+
45+
# run automatically
46+
py "tools/make.py"
3247
```
3348

34-
## Known Issues
35-
- Automatically pressing the scroll lock whilst trying to drag (& drop) in Windows causes the action to stop fail, resulting in unwanted behaviour when selecting or moving objects
49+
## Further Reading
50+
### Useful Links
51+
- https://stackoverflow.com/questions/58273482/can-pyautogui-be-used-to-prevent-windows-screen-lock
52+
- https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate

requirements.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
altgraph == 0.17.3
2+
pefile == 2023.2.7
3+
Pillow == 10.0.0
4+
pip == 23.2.1
5+
pyinstaller == 5.13.0
6+
pyinstaller-hooks-contrib == 2023.6
7+
pystray == 0.19.4
8+
pywin32-ctypes == 0.2.2
9+
setuptools == 65.5.0
10+
six == 1.16.0
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)