caner 8 months ago
parent
commit
6738449c6c
1 changed files with 41 additions and 0 deletions
  1. 41 0
      main.py

+ 41 - 0
main.py

@@ -0,0 +1,41 @@
+import time
+from pymobiledevice3.lockdown import create_using_usbmux
+from pymobiledevice3.services.dvt.instruments.process_control import ProcessControl
+from pymobiledevice3.services.installation_proxy import InstallationProxyService
+from pymobiledevice3.services.dvt.dvt_secure_socket_proxy import DvtSecureSocketProxyService
+from pymobiledevice3.services.remote_fetch_symbols import RemoteService
+import threading
+
+BUNDLE_ID = 'com.laiwang.DingTalk'
+
+def channel():
+    while True:
+        RemoteService.connect("127.0.0.1")
+
+if __name__ == '__main__':
+    try:
+        # 连接手机
+        lockdown = create_using_usbmux()
+        print("开发者模式",lockdown.developer_mode_status)
+        # 获取钉钉-app
+        with InstallationProxyService(lockdown) as installer:
+            # 查找特定应用
+            ddApp = [app for app in installer.get_apps() if 'DingTalk' in app]
+            if len(ddApp):
+                print("找到包",ddApp[0])
+                if ddApp[0] == BUNDLE_ID:
+                    # 打开app
+                    with DvtSecureSocketProxyService(lockdown) as dvt:
+                        process_control = ProcessControl(dvt)
+                        pid = process_control.launch(BUNDLE_ID)
+                        print("启动app",pid)
+                else:
+                    print("包名不匹配")
+            else:
+                print("没找到包,请安装钉钉")
+
+    except ConnectionError as e:
+        print(f"连接失败")
+
+
+