2013-09-26 20 views
0

爲什麼這不起作用,當我使它成爲一個應用程序?我試圖做這個工作,但它所做的只是在finder中敲擊命令而不是終端。它甚至可以在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 

感謝

+0

考慮使用'做外殼script'命令,而不是使用一個終端窗口:'做shell腳本 「開放-a調酒師」' 'do shell script'open -a MobileMouseServer「'等等 – zneak

+0

或者使用'tell application X to activate'來啓動程序:'告訴應用程序Bartender激活','告訴應用程序MobileMouseServer激活,等等。 – zneak

回答

0

考慮這樣的結構:

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