【问题标题】:Why does this not work when I make it an app?为什么当我把它变成一个应用程序时这不起作用?
【发布时间】:2013-09-26 04:23:14
【问题描述】:

为什么当我把它变成一个应用程序时这不起作用?我试图完成这项工作,但它所做的只是击键查找器中的命令而不是终端。它甚至可以在 applescript 编辑器中工作,但不能作为应用程序。请帮忙!

on run
    tell application "Terminal" to quit
    delay 5
    tell application "Terminal" to activate
delay 3
tell application "System Events" to keystroke "n" using {command down}
delay 1
tell application "System Events" to keystroke "top" & return
delay 1
tell application "System Events" to keystroke "n" using {command down}
delay 1
tell application "System Events" to keystroke "open -a Bartender" & return
delay 1
tell application "System Events" to keystroke "open -a MobileMouseServer" & return
delay 1
tell application "System Events" to keystroke "open -a gfxCardStatus" & return
delay 1
tell application "System Events" to keystroke "open -a Caffeine" & return
delay 1
tell application "System Events" to keystroke "open -a Alfred" & return
delay 1
tell application "System Events" to keystroke "open -a smcFanControl" & return
delay 1
tell application "System Events" to keystroke "w" using {command down}

tell application "Finder" to display dialog "System startup successful." with title "T.R.A.V.I.S." with icon file "Macintosh HD:SCRIPTS:ICNS:travis.icns" giving up after 5
end run

谢谢

【问题讨论】:

  • 考虑使用do shell script 命令而不是使用终端窗口:do shell script "open -a Bartender"do shell script "open -a MobileMouseServer" 等。
  • 或者使用tell application X to activate启动程序:tell application Bartender to activatetell application MobileMouseServer to activate

标签: applescript startup


【解决方案1】:

考虑这个结构:

tell application "Terminal"
    if not (exists window 1) then reopen

    -- targets an existing window
    do script "top" in window 1

    -- open a new window
    do script "open -a Bartender"

end tell

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-31
    • 2013-01-26
    • 2016-04-20
    • 1970-01-01
    • 1970-01-01
    • 2015-05-21
    • 2020-05-27
    相关资源
    最近更新 更多