A lightweight, zero-overhead Windows background daemon that automatically manages power plans, screen refresh rates, and display brightness based on physical AC power connection, suitable especially for power-exhaustive gaming laptops.
Unlike bloated third-party software, this script runs entirely native to Windows, utilizing a suspended PowerShell thread to keep CPU usage at exactly 0.00% while running.
- Instant Power State Switching: Automatically toggles between Windows 'High Performance' and 'Power Saver' plans.
- Dynamic Refresh Rate Injection: Uses in-memory compiled C# to step the primary laptop display down to 60Hz on battery, and up to 165Hz when plugged in.
- Multi-Monitor Safe: Automatically detects and ignores external monitors (e.g., 180Hz displays) to prevent accidental refresh rate overrides.
- WMI Brightness Control: Dims the screen to 20% on battery and restores it to 60% on AC power.
- Zero Overhead: Operates via an infinite loop that suspends the thread entirely between checks.
- PowerShell: Serves as the core logic wrapper and background loop daemon.
- C# / .NET On-the-Fly Compilation: Uses
Add-Typeto compile raw C# code directly in memory at runtime. - Windows API (P/Invoke): Hooks directly into
user32.dllto utilizeEnumDisplaySettingsandChangeDisplaySettingsExfor hardware-level screen manipulation. - WMI (Windows Management Instrumentation): Interacts with the motherboard hardware to control backlight brightness natively.
- Compatibility Note: This daemon uses native Windows APIs and works across various laptop brands (Acer, ASUS, Lenovo, Dell, etc.). However, if your laptop includes proprietary control software (like ASUS Armoury Crate, Lenovo Vantage, or Acer NitroSense), you must disable their built-in "Panel Overdrive" or "Auto Refresh Rate" features. If both your manufacturer software and this script attempt to change the refresh rate simultaneously, it may cause screen flickering.
This script is currently optimized for a 165Hz primary display and a 180Hz external monitor. If you are cloning this repository, open AutoPowerSwitcher.ps1 and modify the following values to match your hardware:
- Safety Catch (External Monitors): Change
180to the refresh rate of your external monitor.if (dm.dmDisplayFrequency == 180) { continue; } - High Performance Refresh Rate: Change
165to your laptop's max refresh rate.[ScreenMonitor]::SetRefreshRate(165) - Power Saver Refresh Rate: Standard is 60Hz, but can be modified here:
[ScreenMonitor]::SetRefreshRate(60)
-
Create the Directory
- Create a dedicated folder at
C:\Scripts\ - Place
AutoPowerSwitcher.ps1inside this folder. - Security Note: Ensure standard Windows 'Users' only have "Read & Execute" permissions on this folder to prevent file tampering.
- Create a dedicated folder at
-
Configure Windows Task Scheduler
- Open Task Scheduler and click Create Task... (Not Basic Task).
- General Tab:
- Name:
Auto Power Daemon - CRITICAL: Select the radio button
Run only when user is logged on. (If run in the background without a logged-in user, Windows cannot detect the display to change the refresh rate). - Check:
Run with highest privileges(Required for Powercfg & WMI). - Check:
Hidden
- Name:
- Triggers Tab:
- New Trigger -> Begin the task:
At log on.
- New Trigger -> Begin the task:
- Actions Tab:
- Action:
Start a program - Program/script:
powershell.exe - Add arguments:
-WindowStyle Hidden -ExecutionPolicy Bypass -File "C:\Scripts\AutoPowerSwitcher.ps1"
- Action:
- Conditions Tab:
- CRITICAL: Uncheck "Start the task only if the computer is on AC power".
-
Configure Sleep Settings To prevent the laptop from sleeping while plugged in on the High Performance plan, open an Administrator PowerShell and run:
powercfg /change monitor-timeout-ac 0 powercfg /change standby-timeout-ac 0
This daemon is actively being refined. Planned future features include:
- Custom Fan Curve Integration: Researching methods to interface with OEM Embedded Controllers (EC) via ACPI calls to dynamically adjust fan speeds without relying on proprietary bloatware (e.g., Acer NitroSense).
- Config File Extraction: Moving the hardcoded variables (Refresh Rates, GUIDs, Brightness percentages) out of the
.ps1script and into a standalone.jsonor.iniconfiguration file for easier user customization. - Installer Script: Developing a secondary script to automatically configure the Windows Task Scheduler environment and folder permissions for non-technical users.
This project is open-source and free to use.