iTerm2 Python API 提供了 async_send_text,它接受一個字符串。我可以將“s”字符作為輸入發送到當前會話,但我想知道如何模擬在鍵盤上按下“alt-s”。這是我到目前為止所擁有的:#!/usr/bin/env python3.7import iterm2async 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)
1 回答

胡子哥哥
TA貢獻1825條經驗 獲得超6個贊
當前的 API 不接受帶有 ALT 等修飾符的擊鍵。來自https://gitlab.com/gnachman/iterm2/-/issues/8387
大多數情況下,如果有可用的 API 調用而不是發送擊鍵,則最好使用 API 調用,因為擊鍵僅在某些時候起作用(例如,如果鍵盤焦點位于首選項面板中,則 Cmd-D 不會做任何事情) .
添加回答
舉報
0/150
提交
取消