【问题标题】:AppleScript to Open New Tab in Terminal no longer working in Mountain Lion?AppleScript 在终端中打开新选项卡不再在 Mountain Lion 中工作?
【发布时间】:2012-08-24 08:21:24
【问题描述】:

我曾经在 Lion 中运行以下代码来打开终端,更新项目,然后打开一个新选项卡,然后再次运行以更新第二个、第三个和第四个。自从山狮升级后,这不再有效。一半时间似乎在我的主目录中打开 Finder,另一半时间似乎打开 OSX 字体/文本对话框。我已经确认 Cmd+T 仍应打开一个新选项卡。知道它为什么坏了吗?

tell application "Terminal" to activate

tell application "Terminal"

    do script "cd Projects/blahblah/trunk" in front window
    do script "svn up" in front window

end tell

tell application "System Events" to tell process "Terminal" to keystroke "t" using command down

【问题讨论】:

    标签: applescript osx-mountain-lion


    【解决方案1】:

    事实证明,出于某种原因,我需要告诉终端在每次通话之间激活。狮子从来没有让我这样做。

    tell application "Terminal" to activate
    
    tell application "Terminal"
    
        delay 0.25
    
        do script "cd Projects/firstone/trunk && svn up" in front window
    end tell
    
    tell application "Terminal" to activate
    
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    
    tell application "Terminal"
    
        delay 0.25
    
        do script "cd Projects/secondone/trunk && svn up" in front window
    
    end tell
    

    【讨论】:

    • 从这里 (superuser.com/questions/466619/…) 看来这与tell application "Terminal" to activate 类似
    • tell application "Terminal" to activate tell application "Terminal" delay 0.25 do script "cd Projects/firstone/trunk && svn up" in front window end tell tell application "Terminal" to activate tell application "System Events" to tell process "Terminal" to keystroke "t" using command down tell application "Terminal" delay 0.25 do script "cd Projects/secondone/trunk && svn up" in front window end tell
    猜你喜欢
    • 2012-09-21
    • 2013-06-15
    • 1970-01-01
    • 2012-08-12
    • 2016-12-07
    • 2018-06-28
    • 2013-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多