• python实现模拟器的重启


    import os
    import time
    
    
    class Dnconsole_leidian(object):
        '雷电模拟器启动与关闭'
    
        # 请根据自己电脑配置
        def __init__(self):
            self.console = r'D:\..\..\leidian\LDPlayer4\ldconsole.exe '
    
        def launch(self, index: int):
            '开启'
            cmd = self.console + 'launch --index ' + str(index)
            process = os.popen(cmd)
            result = process.read()
            print(result)
            process.close()
    
        def quit(self, index: int):
            '关闭'
            cmd = self.console + 'quit --index ' + str(index)
            process = os.popen(cmd)
            result = process.read()
            process.close()
            return result
    
    
    # Dnconsole_leidian().quit(0)
    
    
    class Dnconsole_mumu(object):
        '雷电模拟器启动与关闭'
    
        def __init__(self):
            # 请根据自己电脑配置
            self.console = r'D:\..\..\emulator\nemu9\EmulatorShell\NemuPlayer.exe '
    
        def quit_mumu(self):
            '关闭'
            # os.system('taskkill /f /im NemuPlayer.exe') # 需要管理员权限
            os.system("wmic process where name='NemuPlayer.exe' delete")  # 不需要管理员权限
    
        def launch_mumu(self):
            '启动'
            cmd = self.console + 'launch'  # --index ' + str(0)
            os.popen(cmd)
            # os.system(cmd)
            # result = process.read()
            # print(result)
    
        def run(self):
            self.quit_mumu()
            print('关闭MUMU模拟器成功')
            time.sleep(5)
            self.launch_mumu()
            print('打开MUMU模拟器成功')
    
    
    Dnconsole_mumu().run()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
  • 相关阅读:
    nexus 私服 拉不了 jar 包,报 Not authorized
    C++初阶(八)类和对象
    Hive3第二章:简单交互
    2019架构真题&2020案例(四十七)
    回溯法 n皇后
    2024得物校招面试真题汇总及其解答(一)
    python 查找波峰和波谷
    内核态内存映射
    tar解压出错:gzip: stdin: unexpected end of file的解决
    【面试题 - springcloud】- Fegin
  • 原文地址:https://blog.csdn.net/qq_45166384/article/details/125527821