“如何发送”;alt-s";通过iTerm2 Python API

“如何发送”;alt-s";通过iTerm2 Python API,python,iterm2,Python,Iterm2,iTerm2 Python API提供接受字符串的异步发送文本。我可以将“s”字符作为输入发送到当前会话,但我想知道如何模拟按键盘上的“alt-s”。以下是我目前掌握的情况: #!/usr/bin/env python3.7 import iterm2 async def main(connection): app = await iterm2.async_get_app(connection) s = app.current_terminal_window.current_

iTerm2 Python API提供接受字符串的异步发送文本。我可以将“s”字符作为输入发送到当前会话,但我想知道如何模拟按键盘上的“alt-s”。以下是我目前掌握的情况:

#!/usr/bin/env python3.7

import iterm2

async def main(connection):
    app = await iterm2.async_get_app(connection)
    s = app.current_terminal_window.current_tab.current_session
    await s.async_send_text('s')


iterm2.run_until_complete(main)

当前API不接受带有修改器(如ALT.From)的按键行程

大多数情况下,如果API调用可用,则最好使用API调用,而不是发送击键,因为击键只在部分时间有效(例如,如果键盘焦点位于prefs面板中,则Cmd-D不会执行任何操作)