From 14c3ceb4cfad5d03c8d71584dc830d14afd49d44 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=B0=8F=E9=BE=99?= Date: Wed, 22 Jul 2026 13:58:28 +0800 Subject: [PATCH] =?utf8?q?=E5=89=8D=E7=AB=AF=E6=A3=80=E6=B5=8B+=E6=97=A5?= =?utf8?q?=E5=BF=97=E5=8E=BB=E9=87=8D=20v3.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- wechat_auto_login.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/wechat_auto_login.py b/wechat_auto_login.py index 8bd13a9..92093a5 100644 --- a/wechat_auto_login.py +++ b/wechat_auto_login.py @@ -372,6 +372,7 @@ try: self._last_login_hash = None self._user_resized = False self._resend_link_sent = False + self._last_logged_status = "" self._setup_ui() @@ -518,6 +519,9 @@ try: # ── status ── def _set_status(self, text): self.status_var.set(text) + if text != self._last_logged_status: + log.info("状态: %s", text) + self._last_logged_status = text self._update_window_width() def _update_window_width(self): @@ -543,6 +547,18 @@ try: self.root.destroy() log.info("程序退出") + def _is_wechat_foreground(self): + """检查微信是否在前端(活跃窗口),是则不打断用户操作""" + try: + fg_hwnd = win32gui.GetForegroundWindow() + wechat_wins = _find_wechat_windows() + for w in wechat_wins: + if hasattr(w, '_hWnd') and w._hWnd == fg_hwnd: + return True + except Exception: + pass + return False + # ── main loop (every 5 seconds) ── def _main_loop_tick(self): if not self.running: @@ -600,8 +616,12 @@ try: return # ④ 最小化其他窗口 - _minimize_all_except_wechat() - time.sleep(0.3) + # 微信在前端就不最小化,避免打断用户 + if not self._is_wechat_foreground(): + _minimize_all_except_wechat() + time.sleep(0.3) + else: + time.sleep(0.3) # 再次确认窗口尺寸(最小化后可能有窗口挡住微信) wechat_windows = _find_wechat_windows() @@ -733,8 +753,10 @@ try: return # ④ 截图+哈希比较 - _minimize_all_except_wechat() - time.sleep(0.3) + # 微信在前端就不最小化 + if not self._is_wechat_foreground(): + _minimize_all_except_wechat() + time.sleep(0.3) img = _capture_center() new_md5 = _md5_of_image(img) -- 2.43.0