main.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import time
  2. from pymobiledevice3.lockdown import create_using_usbmux
  3. from pymobiledevice3.services.dvt.instruments.process_control import ProcessControl
  4. from pymobiledevice3.services.installation_proxy import InstallationProxyService
  5. from pymobiledevice3.services.dvt.dvt_secure_socket_proxy import DvtSecureSocketProxyService
  6. from pymobiledevice3.services.remote_fetch_symbols import RemoteService
  7. import threading
  8. BUNDLE_ID = 'com.laiwang.DingTalk'
  9. def channel():
  10. # pymobiledevice3 remote start-tunnel
  11. while True:
  12. RemoteService.connect()
  13. if __name__ == '__main__':
  14. try:
  15. # 启动隧道服务线程
  16. # 连接手机
  17. lockdown = create_using_usbmux()
  18. print("开发者模式",lockdown.developer_mode_status)
  19. # 获取钉钉-app
  20. with InstallationProxyService(lockdown) as installer:
  21. # 查找特定应用
  22. ddApp = [app for app in installer.get_apps() if 'DingTalk' in app]
  23. if len(ddApp):
  24. print("找到包",ddApp[0])
  25. if ddApp[0] == BUNDLE_ID:
  26. # 打开app
  27. with DvtSecureSocketProxyService(lockdown) as dvt:
  28. process_control = ProcessControl(dvt)
  29. pid = process_control.launch(BUNDLE_ID)
  30. print("启动app",pid)
  31. else:
  32. print("包名不匹配")
  33. else:
  34. print("没找到包,请安装钉钉")
  35. except ConnectionError as e:
  36. print(f"连接失败")