【问题标题】:Applescript to change shortcut to be able to clear lines in iTerm2Applescript 更改快捷方式以便能够清除 iTerm2 中的行
【发布时间】:2021-11-28 21:07:28
【问题描述】:

我正在尝试制作一个能够 cmd+L 获取 ctrl+L 的applescript按照answer 的建议清除 iTerm 中的行。

here 复制一个有效的示例applescript,如下所示,

tell application "System Events" to keystroke "l" using control down

我正在尝试将应用程序更改为“iTerm2”,如下所示,

tell application "iTerm2" to keystroke "l" using control down

所以快捷方式不是全局的,但我得到一个语法错误:

标识符不能跟在这个“”之后。

删除引号(这也适用于工作示例)会带来不同的语法错误:

“一个标识符不能跟在这个标识符之后。”

我做错了什么?

【问题讨论】:

  • iTerm 没有名为 keystroke 的方法。你必须activate iTerm 然后tell application "System Events" to keystroke "l" using control down

标签: applescript iterm2


【解决方案1】:

感谢@gurkensaas 对正确答案的评论。我在下面为其他人发布了完整的工作脚本。

tell application "iTerm" to activate
delay 0.1
tell application "System Events"
    try
        keystroke "l" using control down
    end try
end tell

编辑:我最终为这个快捷方式使用了 Better Touch Tool,因为它响应速度更快。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-22
    相关资源
    最近更新 更多