From aa7b86562493801bbdc240e66e0f2e6190bd77ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=88=E6=A3=AE=E5=90=B4?= <8402134@qq.com> Date: Thu, 10 Nov 2022 20:11:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BF=80=E6=B4=BB=E5=BE=AE=E4=BF=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PCRobot/PCRobotForm.cs | 2 +- PCRobot/Utils/WeChatActivateHelper.cs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/PCRobot/PCRobotForm.cs b/PCRobot/PCRobotForm.cs index b3324a6..2957eff 100644 --- a/PCRobot/PCRobotForm.cs +++ b/PCRobot/PCRobotForm.cs @@ -42,7 +42,7 @@ namespace PCRobot try { - WeChatActivateHelper.Init(TimeSpan.FromMinutes(20)); + WeChatActivateHelper.Init(TimeSpan.FromMinutes(40)); } catch (Exception exception) { } diff --git a/PCRobot/Utils/WeChatActivateHelper.cs b/PCRobot/Utils/WeChatActivateHelper.cs index d912a54..b414d4e 100644 --- a/PCRobot/Utils/WeChatActivateHelper.cs +++ b/PCRobot/Utils/WeChatActivateHelper.cs @@ -115,7 +115,7 @@ namespace WechatHelper if (isIconic) { ShowWindow(handle, 1); - Thread.Sleep(new Random(Guid.NewGuid().GetHashCode()).Next(8000, 10000)); + Thread.Sleep(1000); } var thisHandel = Process.GetCurrentProcess().MainWindowHandle; @@ -153,10 +153,16 @@ namespace WechatHelper }, null); //如果微信最小化了,重新让他最小化 - if (!isIconic) continue; + + if (isIconic) + { + Thread.Sleep(1000); + ShowWindow(handle, 2); + } + //休眠 Thread.Sleep(new Random(Guid.NewGuid().GetHashCode()).Next(40000, 60000)); - ShowWindow(handle, 2); + } while (true); } catch (Exception e) @@ -178,7 +184,7 @@ namespace WechatHelper { try { - Thread.Sleep(1000); + Thread.Sleep(5000); var rstHandlePtr = FindWindowExA(IntPtr.Zero, handle, className, windowName); if (handle == IntPtr.Zero) break; if (handleList.Contains(handle)) break;