繁体   English   中英

无法同时打开多个程序

[英]Can't open multiple programs at once

我正在编写 Python 3 中的一段代码,该代码充当各种白天作弊的接口。 我正在使用一个非常基本的设置,只需 input() 和 os.system() 来查找和打开特定文件。 它工作正常,但有一个小问题。

该界面使用 cmd 提示符,我已将其设置为输入数字 1-4 将打开用于修改游戏的程序和可执行文件。 但是,某些程序需要在其他程序运行时保持打开状态。 例如,BVHR Session Grabber 必须与 SaveInjector Interface 一起运行,因为 SaveInjector 需要从 Grabber 接收某个代码。

这里有一个问题,代码的设置方式使您一次只能运行一个文件。 我不确定究竟是什么导致了这种情况,但我会尝试解释会发生什么。 例如,当在 cmd 提示窗口中输入数字 1 时,它会打开 BHVR Session Grabber(按预期)。 之后,界面将无法使用,直到我关闭 BHVR Session Grabber。 当它处于活动状态时,我无法在其中输入任何内容,因此我无法一次打开多个程序。

不完全确定这是否是有意的,但我希望这是可以避免的。 如果有人对此问题有任何了解,请让我知道如何在评论中找到解决方法。

import os.path
def interface():
    os.system('cls' if os.name == 'nt' else 'clear')
    print("""
    \n\nSelect a cheat below:
    \n
    \n1: BHVR Session Grabber
    \n2: SaveInjector Interface
    \n3: Rank / Shards Editor
    \n4: Exit\n
    """)

def checker():
    interface()
    lst = ['1','2','3','4']
    good_input = input(">")

    global user_input
    user_input = None
    while not user_input:
        if good_input in lst: 
            user_input = good_input
        else:
            print("Enter a valid integer.")
            good_input = input(">")
        
checker()
cwd = os.getcwd()

def selection():
    if user_input == '1':
        f = (os.path.join(cwd, 'Programs', 'BHVRSession', 'CookieFinder.exe'));
        os.system(f)
        checker()
        selection()
        
    elif user_input == '2':
        os.system('cmd /k "cd Programs & cd Injector & SI.exe & cd.. & cd.. & Ultimate.py"')
        
    elif user_input == '3':
        f = (os.path.join(cwd, 'Programs', 'RankShards', 'Sender.exe'));
        os.system(f)
        checker()
        selection()
        
    elif user_input == '4':
        os.system('cmd /k "taskkill/im py.exe"')

selection()

这里的问题是os.system()正在阻塞。 这意味着它只会在它运行的程序完成后返回并继续执行你的 Python 代码。 相反,您应该查看subprocess包以了解如何创建一个可以与您的 Python 程序并行运行的新进程。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM