- Add wxauto package with WeChat UI automation and message handling capabilities - Implement job_extractor.py for automated job posting extraction from WeChat groups - Add job_extractor_gui.py providing graphical interface for job extraction tool - Create comprehensive documentation in Chinese covering GUI usage, multi-group support, and quick start guides - Add build configuration files (build_exe.py, build_exe.spec) for packaging as standalone executable - Include utility scripts for WeChat interaction (auto_send_msg.py, get_history.py, receive_file_transfer.py) - Add project configuration files (pyproject.toml, setup.cfg, requirements.txt) - Include test files (test_api.py, test_com_fix.py) for API and compatibility validation - Add Apache 2.0 LICENSE and comprehensive README documentation - Configure .gitignore to exclude build artifacts, logs, and temporary files
115 lines
3.2 KiB
Python
115 lines
3.2 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""
|
||
测试COM组件初始化修复
|
||
用于验证打包后的程序是否能正常工作
|
||
"""
|
||
import sys
|
||
import threading
|
||
import time
|
||
|
||
def test_com_in_thread():
|
||
"""在线程中测试COM初始化"""
|
||
print("\n[线程测试] 开始...")
|
||
|
||
try:
|
||
import pythoncom
|
||
print("[线程测试] ✓ pythoncom模块导入成功")
|
||
except ImportError as e:
|
||
print(f"[线程测试] × pythoncom模块导入失败: {e}")
|
||
print("请运行: pip install pywin32")
|
||
return False
|
||
|
||
try:
|
||
# 初始化COM
|
||
pythoncom.CoInitialize()
|
||
print("[线程测试] ✓ COM组件初始化成功")
|
||
|
||
# 尝试使用wxauto
|
||
try:
|
||
from wxauto import WeChat
|
||
print("[线程测试] ✓ wxauto模块导入成功")
|
||
|
||
# 注意:这里不实际连接微信,只测试导入
|
||
print("[线程测试] ✓ 所有测试通过")
|
||
result = True
|
||
|
||
except Exception as e:
|
||
print(f"[线程测试] × wxauto测试失败: {e}")
|
||
result = False
|
||
|
||
# 清理COM
|
||
pythoncom.CoUninitialize()
|
||
print("[线程测试] ✓ COM组件清理成功")
|
||
|
||
return result
|
||
|
||
except Exception as e:
|
||
print(f"[线程测试] × COM初始化失败: {e}")
|
||
return False
|
||
|
||
|
||
def main():
|
||
print("=" * 60)
|
||
print("COM组件修复验证测试")
|
||
print("=" * 60)
|
||
|
||
# 测试1:主线程导入
|
||
print("\n[测试1] 主线程模块导入...")
|
||
try:
|
||
import pythoncom
|
||
print("✓ pythoncom导入成功")
|
||
except ImportError as e:
|
||
print(f"× pythoncom导入失败: {e}")
|
||
print("\n请先安装pywin32:")
|
||
print(" pip install pywin32")
|
||
return
|
||
|
||
try:
|
||
from wxauto import WeChat
|
||
print("✓ wxauto导入成功")
|
||
except ImportError as e:
|
||
print(f"× wxauto导入失败: {e}")
|
||
print("\n请先安装wxauto:")
|
||
print(" pip install -e .")
|
||
return
|
||
|
||
# 测试2:工作线程中的COM初始化
|
||
print("\n[测试2] 工作线程COM初始化...")
|
||
thread = threading.Thread(target=test_com_in_thread)
|
||
thread.start()
|
||
thread.join()
|
||
|
||
# 测试3:检查打包相关模块
|
||
print("\n[测试3] 检查打包相关模块...")
|
||
modules_to_check = [
|
||
'pywintypes',
|
||
'win32com',
|
||
'win32api',
|
||
'win32con',
|
||
'win32gui',
|
||
]
|
||
|
||
all_ok = True
|
||
for module_name in modules_to_check:
|
||
try:
|
||
__import__(module_name)
|
||
print(f"✓ {module_name}")
|
||
except ImportError:
|
||
print(f"× {module_name} (可选)")
|
||
|
||
# 总结
|
||
print("\n" + "=" * 60)
|
||
print("测试完成")
|
||
print("=" * 60)
|
||
print("\n如果所有测试都通过,说明修复成功,可以进行打包。")
|
||
print("打包命令:")
|
||
print(" 方式1: 双击 修复并重新打包.bat")
|
||
print(" 方式2: 双击 build.bat")
|
||
print(" 方式3: pyinstaller build_exe.spec")
|
||
print("\n打包后请测试exe文件,确保能正常连接微信。")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|
||
input("\n按回车键退出...")
|