import subprocess
import time

def start_program(program_name):
    # 使用虚拟环境中的 Python 解释器来运行程序
    return subprocess.Popen(['venv/Scripts/python', program_name])

if __name__ == '__main__':
    # 启动两个程序
    process1 = start_program('scanf_face.py')
    process2 = start_program('app.py')

    try:
        # 等待程序结束（在此示例中，程序会一直运行，因此不会到达这一步）
        process1.wait()
        process2.wait()
    except KeyboardInterrupt:
        # 捕获 Ctrl+C 来终止程序
        print("Terminating processes...")
        process1.terminate()
        process2.terminate()
        process1.wait()
        process2.wait()
