Skip to content

About

Windows tray app for battery-aware power profiles, display refresh rates, notifications and AC-safe recovery.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

BatteryAutoProfileApp / 笔记本离电自动省电工具

Windows .NET Framework Power License

About Me / 关于我

I am Dxir. I turn scattered interests, data, and practice into things people can open, use, verify, and keep exploring: Windows automation, local analytics, game tooling, and lightweight web products.

我是 Dxir。我喜欢把零散的兴趣、数据与实践,做成别人可以真正进入、使用、验证并继续探索的东西:Windows 自动化、本地数据分析、游戏工具和轻量 Web 产品。

Overview / 项目概览

BatteryAutoProfileApp is a lightweight Windows tray application for laptop power automation. It applies battery-only optimizations after AC power is disconnected, then restores the plugged-in experience when AC power returns.

BatteryAutoProfileApp 是一个轻量 Windows 托盘小软件:拔电后自动执行省电配置,接电后自动恢复满血体验。它适合微信、QQ、多网页、文档、ChatGPT/Codex、会议等办公负载,同时不牺牲接电时的游戏性能、高刷新率和 Steam 体验。

Design Goals / 设计目标

English 中文
Never reduce plugged-in performance 接电时不限制 CPU/GPU,不关闭游戏相关能力
Apply power saving only on battery 所有降功耗动作只在离电后执行
Restore automatically on AC 接回电源后自动恢复触摸屏、刷新率与性能设置
Run as a tray app, without a visible PowerShell window 以托盘小软件运行,不常驻 PowerShell 窗口
Show topmost foreground notifications 进入/离开离电模式时显示置顶通知
Match the touchscreen by exact device id 精确匹配触摸屏设备,避免误伤触摸板

Features / 功能

Scenario English 中文
Battery Enable Windows Energy Saver related settings 启用 Windows 节能相关设置
Battery Set DC brightness and Energy Saver brightness preference 设置离电亮度目标与节能亮度权重
Battery Set battery hibernation timeout 设置离电自动休眠时间
Battery Switch refresh rate to a configured maximum 将刷新率切到不超过配置值的显示模式
Battery Stop configured background processes such as Steam 关闭配置中的非办公后台进程,例如 Steam
Battery Disable configured touchscreen through elevated/SYSTEM task 通过管理员或 SYSTEM 任务禁用触摸屏
AC Keep CPU maximum processor state at 100% 接电时保持 CPU 最大处理器状态 100%
AC Restore the last known plugged-in display mode 恢复接电显示模式和刷新率
AC Re-enable the configured touchscreen 自动重新启用触摸屏
Logon Calibrate state after startup/logon 启动或登录后按当前电源状态校准

Topmost Notification / 置顶通知

The app uses a topmost foreground window instead of an easy-to-miss toast. Each mode switch shows:

小软件不依赖容易被忽略的普通 toast,而是显示置顶前台窗口。每次切换模式时会展示:

  • Current mode: on battery or plugged in / 当前模式:已离电或已接电
  • Complete feature list / 小软件完整功能
  • Actions executed, skipped, or failed in this run / 本次实际执行、跳过、失败的项目
  • Touchscreen administrator task status / 触摸屏管理员任务状态
  • Current config file path / 当前配置文件路径

SmartRefreshRate Integration / 刷新率集成

This project integrates the core idea of SmartRefreshRate: enumerate display modes through Win32 display APIs and switch refresh rate when AC/DC state changes.

本项目集成了 SmartRefreshRate 的核心思路:通过 Win32 显示 API 枚举显示模式,并在接电/离电切换时调整刷新率。

Related APIs / 相关 API:

  • EnumDisplayDevices
  • EnumDisplaySettings
  • ChangeDisplaySettingsEx

Upstream / 上游项目:Mefgner/Smart-Refresh-Rate

Third-party license notes are listed in THIRD_PARTY_NOTICES.txt.

第三方许可归属见 THIRD_PARTY_NOTICES.txt。

Install / 安装

Place the compiled executable in a stable directory, for example:

把编译好的 BatteryAutoProfileApp.exe 放到稳定目录,例如:

D:\software\BatteryAutoProfileApp\BatteryAutoProfileApp.exe

The app creates local runtime files beside the exe:

第一次启动后,会在 exe 同目录生成:

BatteryAutoProfile.config.json
BatteryAutoProfileApp.log
LastPowerState.txt

Enable or disable startup:

开启或关闭自启动:

.\BatteryAutoProfileApp.exe --enable-autostart
.\BatteryAutoProfileApp.exe --disable-autostart

The same controls are also available from the tray menu.

也可以在托盘菜单里直接开启或关闭。

Touchscreen Control / 触摸屏控制

Disabling or enabling PnP devices requires administrator or SYSTEM permission, so touchscreen control is delegated to an elevated scheduled task.

禁用或启用 PnP 设备需要管理员或 SYSTEM 权限,因此触摸屏控制由专用计划任务执行。

Recommended setup / 推荐安装方式:

scripts\Install-Touchscreen-Admin-Task.cmd

Or use the tray menu item / 或在托盘菜单中点击:

安装触摸屏管理员任务

After installation, power-state changes trigger --device-only, which runs the touchscreen operation under SYSTEM permission.

任务安装后,电源状态变化会触发 --device-only 模式,由 SYSTEM 权限执行触摸屏启停。

Find touchscreen devices / 查找触摸屏设备:

Get-PnpDevice -Class HIDClass | Where-Object {
  $_.FriendlyName -match 'touch|触摸'
}

If a HID touchscreen child device cannot be disabled by itself, configure the parent controller only after confirming it belongs to the touchscreen path:

如果 HID 触摸屏子设备无法单独禁用,只能在确认父设备属于触摸屏链路后配置父控制器:

"DisableTouchControllerFallback": true

Do not put touchpads, keyboards, external receivers, or uncertain controllers into the touchscreen field.

不要把触摸板、键盘、外设接收器或不确定的控制器填进触摸屏配置。

Configuration / 配置

Copy config/BatteryAutoProfile.config.example.json beside the exe and adjust it for your device.

复制 config/BatteryAutoProfile.config.example.json 到 exe 同目录,并按设备调整。

{
  "TouchScreenInstanceId": "",
  "TouchControllerInstanceId": "",
  "DisableTouchScreenOnBattery": true,
  "DisableTouchControllerFallback": false,
  "BatteryBrightnessPercent": 42,
  "BatteryEnergySaverBrightnessPercent": 45,
  "BatteryEnergySaverThresholdPercent": 100,
  "BatteryHibernateAfterMinutes": 60,
  "BatteryCpuMaxPercent": 100,
  "BatteryCpuMaxPercentWhenLimited": 99,
  "LimitCpuBoostOnBattery": false,
  "StopProcessesOnBattery": [
    "steam",
    "steamwebhelper"
  ],
  "RefreshRateIntegrationEnabled": true,
  "BatteryRefreshRateMaxHz": 60,
  "PopupNotifications": true,
  "PopupTimeoutSeconds": 25
}

Build / 构建

Requirements / 环境要求:

  • Windows 10 / Windows 11
  • .NET Framework compiler: csc.exe
  • PowerShell
.\scripts\build.ps1

Output / 输出:

dist\BatteryAutoProfileApp.exe

CLI / 命令行

--enable-autostart                 Enable startup for the current exe / 开启当前 exe 自启动
--disable-autostart                Disable startup / 关闭自启动
--install-elevated-device-tasks    Install elevated device tasks / 安装触摸屏管理员任务
--device-only                      Run only touchscreen operation / 只执行触摸屏启停
--test-notify                      Show a topmost test notification / 显示置顶测试通知

Safety Boundary / 安全边界

  • No device id is filled by default / 默认不填写任何设备 ID
  • Without TouchScreenInstanceId, no touch device is disabled / 未配置触摸屏 ID 时不会禁用触摸设备
  • Touchscreen operations are not forced from normal user permission / 普通权限下不会硬执行触摸屏禁用
  • Plugged-in mode does not reduce performance, close Steam, or limit refresh rate / 接电时不降低性能、不关闭 Steam、不限制刷新率
  • Runtime logs and local configs are ignored by Git / 日志和本地配置不会提交到仓库

License / 许可证

MIT. See LICENSE.

About

Windows tray app for battery-aware power profiles, display refresh rates, notifications and AC-safe recovery.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages