QQ托盘隐藏时跳过poll不尝试恢复窗口: 任何ShowWindow(SW_SHOWNORMAL)在隐藏QQ NT窗口上都会触发托盘预览弹窗而非恢复主窗口

This commit is contained in:
youpaishidifu
2026-07-26 17:57:15 +08:00
parent 6bc8885eae
commit 0775ceaea7
+5 -13
View File
@@ -1472,10 +1472,11 @@ class MessageMonitor:
logger.debug(f"[{platform}] 窗口未找到")
return
# QQ: 记录窗口是否处于托盘隐藏状态,用于 poll 结束后自动缩回托盘
qq_was_hidden = (platform == "qq" and hwnd
and win32gui.IsWindow(hwnd)
and not win32gui.IsWindowVisible(hwnd))
# QQ 在托盘隐藏(IsWindowVisible=False)时跳过本轮。
# 任何尝试恢复隐藏窗口的操作(SW_SHOWNORMAL 等)在 QQ NT 上都会触发托盘预览弹窗,
# 不会恢复主聊天窗口。用户保持 QQ 窗口最小化到任务栏即可。
if platform == "qq" and hwnd and win32gui.IsWindow(hwnd) and not win32gui.IsWindowVisible(hwnd):
return
# 2. 从 HWND 创建全新 Control(绕过缓存)
win = self._fresh_window(platform)
@@ -1587,15 +1588,6 @@ class MessageMonitor:
self._cached_hwnd.pop(platform, None)
self._cached_pid.pop(platform, None)
# QQ: poll 结束后,如果之前是托盘隐藏状态,缩回托盘(不留窗口在桌面)
if qq_was_hidden:
try:
if win32gui.IsWindow(hwnd):
win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
except Exception:
pass
def _clean_old_ocr_debug(dir_path: str, keep: int = 20):
"""清理 ocr_debug_*.png 文件,只保留最近 keep 张。"""
try: