Skip to content

Conversation

@wustghj
Copy link
Contributor

@wustghj wustghj commented Aug 27, 2025

1. 解决发送消息有概率卡死

  • 点击发送后,在搜索联系人一栏卡死
  • 推测原因是打开微信exe之后,微信界面还未完全加载,就开始查找联系人控件,因此添加一个短sleep,防止卡死
image

2. 优化定时发送功能

  • 我的系统win10 ,19045.6216 Version, 微信 3.9.12.55 Version,实测定时发送功能失效,以下是报错信息
795c3f3419e8f9493c5f1c84cdcb916b
  • 调试排查,原因是定时发送是在非主线程中,经查证uiautomation 库在 Windows 下多线程里直接调用 UIAutomation API 时,要调用 CoInitialize,因此在定时线程的run函数上添加上
    import uiautomation as auto
    with auto.UIAutomationInitializerInThread():
    
    后可以成功定时发送
  • 调整定时发送逻辑,将原本60s的轮询优化为根据定时计算,精确唤醒发送线程
      1. 稍微提高性能; 避免由于定时开启时的极限时间如xx分59秒开始,导致下次发消息由于操作延时错过定时时间

@LTEnjoy
Copy link
Owner

LTEnjoy commented Aug 28, 2025

你好,感谢你的贡献!我查看了修改的文件,没有什么大问题。不过在更新后的代码中,如果默认休眠时间设置为60s,会导致一个特殊的边界情况:

当用户设置的定时时间就是目前的标准时间时,开启定时后sleep_seconds不会被前面的判断条件修改,还是会保持默认的60s。但实际上这种时候让发送操作立即执行是比较好的。因此我觉得可以将sleep_seconds的默认值改为0

@wustghj
Copy link
Contributor Author

wustghj commented Aug 29, 2025

@LTEnjoy 感谢大佬的细心指正,在特殊场景下确实会触发该边界问题,已修正

Copy link
Owner

@LTEnjoy LTEnjoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常感谢你的贡献!稍后我会发布针对修改后的新的exe程序。

@LTEnjoy LTEnjoy merged commit 7ea312a into LTEnjoy:main Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants