Art*_*hou 2 mac iterm applescript
我正在尝试将文本从 Apple 脚本粘贴到 iTerm。
\n\nactivate application "iTerm"\ntell application "iTerm"\n tell current tab of current window\n set cmd to "command"\n keystroke cmd\n keystroke return\n end tell\nend tell\nRun Code Online (Sandbox Code Playgroud)\n\n但我收到错误:
\n\n\n\n\niTerm 出现错误:Can\xe2\x80\x99t 获取当前窗口当前选项卡的击键“命令”。
\n
任何想法如何解决这一问题?
\n\n正如我在这里有可用的write text命令https://www.iterm2.com/documentation-scripting.html
该write text 命令是在 中完成的current session,因此请使用以下示例 AppleScript 代码:
activate application "iTerm"
tell application "iTerm"
tell current session of current window
set cmd to "command"
write text cmd
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
要使用该keystroke 命令,请使用System Events:
activate application "iTerm"
tell application "iTerm"
tell current tab of current window
set cmd to "command"
tell application "System Events"
keystroke cmd
keystroke return
end tell
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
注意:您可能需要策略性地放置一个delay 命令,以允许iTermwrite text在执行或keystroke 命令之前完全激活。
| 归档时间: |
|
| 查看次数: |
2564 次 |
| 最近记录: |