Automation 如何通过pexpect向ncurses应用程序发送控制(按键向下)

Automation 如何通过pexpect向ncurses应用程序发送控制(按键向下),automation,command-line-interface,ncurses,pexpect,Automation,Command Line Interface,Ncurses,Pexpect,我用ncurses编写了Linux应用程序。我正在尝试使用pexpect实现自动化,但没有成功 我可以生成应用程序并处理输出,但无法发送向下箭头键: import pexpect import time import sys, os os.environ['LINES'] = "25" os.environ['COLUMNS'] = "80" child=pexpect.spawn("my_ncurses_app", maxrea

我用ncurses编写了Linux应用程序。我正在尝试使用pexpect实现自动化,但没有成功

我可以生成应用程序并处理输出,但无法发送向下箭头键:

import pexpect
import time 
import sys, os

os.environ['LINES'] = "25"
os.environ['COLUMNS'] = "80"

child=pexpect.spawn("my_ncurses_app", maxread=4000, encoding="utf-8")
child.logfile=sys.stdout
child.setwinsize(25,80)

KEY_DOWN = '\033[B'

#close button appears on screen, After that I want to press down key twice and enter
child.expect("Close")

#ncurses_app sees KEY_DOWN as 3 different keys \033, [, B
child.send(KEY_DOWN)
child.send(KEY_DOWN)

child.sendline()
#ncurses_app sees enter as Int(10)
它适用于其他CLI应用程序,但不适用于我的应用程序

调试显示应用程序看到的不是1个向下箭头符号,而是3个不同的键

如何将密钥作为一个符号发送?可能我应该使用smth other而不是PEEXPECT,smth与流程进行低级交互?

您需要a来获得有用的响应。您需要a来获得有用的响应。