Skip to content

v1.0.4

Choose a tag to compare

@informalgit informalgit released this 07 Sep 03:04
· 9 commits to main since this release

Alt+Tab 应用切换器 v1.0.4。

二进制见下方 Assets 中的 AltTabSwitcher.exe(启动即申请管理员权限);源码用户请 clone 后执行 build.bat 自行构建(exelog 不入库)。

主要变更

  • 修复双重 commit 竞态Application.DoEvents() 会把第二个提交触发(watchdog tick / 排队的 WM_APP_COMMIT)泵成嵌套 Commit;内层激活目标、结束会话后,外层继续重试并失败,最终把前台还给源窗口(表现为"Microsoft To Do 一直前置")。现已加入重入守卫与幂等收尾,Commit 入口先解除全部会话级触发源。
  • 失败兜底改为三分支:只有当前台丢失(0x0)或停留在自身浮层时才归还源窗口,绝不从第三方持有者手里抢回前台。
  • 日志调用移出低级键盘钩子回调LowLevelHooksTimeout 会静默移除执行 I/O 的钩子),改在消息处理处记录热键链路。
  • 窗口合格性判定合并为单一 AltTabIneligibilityReason(同时服务过滤与日志,避免两份逻辑漂移),owner 链遍历抽为 OwnerChainRepresentative
  • 文件内结构拆分NativeMethods(P/Invoke、常量、结构体、COM)、Logic(纯布局与排序逻辑,对应 PowerToys AltWindowCycleLogic.h)、AppEntry 提升到命名空间级。
  • 构建build.bat 嵌入 app.manifest,声明 requireAdministratorPerMonitorV2 DPI 感知。

运行要求

  • 需以管理员权限运行:当前台窗口属于提权进程时,线程附加、前台激活以及读取其 exe 名与图标都需要提权。
  • 编译前请先从托盘退出正在运行的实例(或右键以管理员身份运行 build.bat):提权后的实例无法被普通命令行的 taskkill 结束,否则输出文件被占用会导致编译失败。

已知问题

  • 切换到 UWP 目标(如 Microsoft To Do)的激活仍在排查中。
  • 单应用时按键被吞但无响应、最小化窗口的恢复为已知待办项。

English

Alt+Tab application switcher v1.0.4. Download AltTabSwitcher.exe from Assets (requests elevation on launch); to build from source, clone the repository and run build.bat (exe and log files are intentionally not tracked).

Changes

  • Fixed the double-commit race. Application.DoEvents() pumped a second commit trigger (watchdog tick or queued WM_APP_COMMIT) into a nested Commit; the inner one activated the target and ended the session, while the outer one kept retrying, failed, and handed the foreground back to the source window ("Microsoft To Do stays in front"). Added a reentrancy guard plus idempotent teardown; Commit now disarms every session-scoped trigger before doing any work.
  • Three-branch failure fallback. The source window is restored only when the foreground is lost (NULL) or held by our own overlay — never yanked from a foreign holder.
  • Logging moved out of the low-level keyboard hook callback (LowLevelHooksTimeout silently removes hooks that perform I/O).
  • Single window-eligibility predicate (AltTabIneligibilityReason) serving both filtering and logging; owner-chain walk extracted to OwnerChainRepresentative.
  • In-file structural split: NativeMethods, Logic (pure layout/cycle math mirroring PowerToys AltWindowCycleLogic.h), AppEntry.
  • Build: build.bat now embeds app.manifest (requireAdministrator, PerMonitorV2 DPI awareness).

Requirements

  • Must run elevated: attaching to, activating, and querying windows owned by elevated processes all require admin rights.
  • Exit the running instance from the tray before rebuilding (or run build.bat as administrator) — taskkill from a non-elevated shell cannot terminate an elevated instance, and the locked output file breaks the build.

Known issues

  • Activating a UWP target (e.g. Microsoft To Do) is still under investigation.
  • Key swallowed without response when only one application is running, and restoring minimized windows, remain open items.