From ee6a24f736a1a66dcf04332409a425d1edbdd41d Mon Sep 17 00:00:00 2001 From: ERR0RPR0MPT Date: Sun, 14 Apr 2024 07:37:11 +0800 Subject: [PATCH] update: fix subprocess input pipe bug --- main.py | 6 ++++-- start.bat | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index dfa641e..053ff08 100644 --- a/main.py +++ b/main.py @@ -252,7 +252,7 @@ def getevent(): touch_index = 0 # 执行 adb shell getevent 命令并捕获输出 - process = subprocess.Popen(['adb', 'shell', 'getevent', '-l'], stdout=subprocess.PIPE) + process = subprocess.Popen(['adb', 'shell', 'getevent', '-l'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) key_is_changed = False # 读取实时输出 @@ -338,7 +338,9 @@ if __name__ == "__main__": serial_manager.start() threading.Thread(target=getevent).start() while True: - input_str = input() + input_str = input().strip() + if len(input_str) == 0: + continue if input_str == 'start': serial_manager.startUp = True print("已连接到游戏") diff --git a/start.bat b/start.bat index 51020fb..1568968 100644 --- a/start.bat +++ b/start.bat @@ -1,3 +1,2 @@ @echo off python .\main.py -pause \ No newline at end of file