A simple Python script for quickly switching the screen resolution between two preset values.
I use it only to quickly change my resolution when I want to play CS2, so it matches my in-game resolution.
The script checks the current monitor resolution, compares it with two preset values, and switches it to the other saved resolution.
- If the first resolution is currently active, it switches to the second one.
- If the second one is active, it switches back to the first one.
To make the script run with a single PowerShell command, add a custom function to your PowerShell profile.
- If the profile does not exist yet, create it and open it:
if (!(Test-Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
notepad $PROFILE- Add a function like this:
function disp { & "PATH_TO_PYTHONW" "PATH_TO_SCRIPT" }- Replace:
PATH_TO_PYTHONWwith the path topythonw.exeinside the virtual environment.PATH_TO_SCRIPTwith the path to the Python script.
After saving the PowerShell profile, start the script with:
dispThis allows the script to run instantly without opening the project manually.
Personal file paths and folder names are intentionally hidden in this README.