Iterm2使用AppleScript启用广播输入快捷方式

时间:2018-07-19 00:17:11

标签: applescript iterm2

是否可以通过两个会话启用一个Iterm2实例,并使用AppleScripts在两个会话上启用广播输入快捷方式功能?

我一直在尝试至少使用击键来启用它,但我无法做到这一点。

下面是代码示例:

    tell application "iTerm"
        activate
    end tell
    tell application "iTerm"
        tell current window
            set newWindow to (create tab with default profile)
            tell current session of newWindow
                split horizontally with same profile
            end tell
            tell session 1 of newWindow
                set transparency to 0.5
                write text "clear"
                delay 1         
            end tell
            tell session 2 of newWindow
                set transparency to 0.5
                write text "clear"
                delay 1
            end tell
        end tell
        -- keystroke "L" using {control down, option down, command down, shift down}
    end tell

我不是在问代码,只是问命令或解决问题的正确方法。

1 个答案:

答案 0 :(得分:0)

这可能不再适合您的情况了,但是对于像我一样通过google在这里冲浪的用户来说,到目前为止,我发现的有效解决方案是在通过{{1}发出设置的快捷方式之前添加适当的延迟}。

查找此延迟的最佳位置取决于您的iTerm在发出窗口和会话命令后准备就绪的速度。

以下是我的多ssh会话脚本的内容:

System Events