|
1 | | -# "Stay Awake, Don't Sleep!" utility (in Python)  |
| 1 | +# awake |
| 2 | +prevent the system from entering sleep or turning off the display |
2 | 3 |
|
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) |
5 | 11 |
|
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. |
7 | 16 |
|
8 | 17 | ## Usage |
9 | | -The App starts in the system tray (with the  icon). |
| 18 | +The App starts in the system tray (with the [Z] icon). |
10 | 19 |
|
11 | 20 |  |
12 | 21 |
|
13 | 22 | 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. |
14 | 23 |
|
15 | 24 |  |
16 | 25 |
|
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" |
32 | 47 | ``` |
33 | 48 |
|
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 |
0 commit comments