我不知道我在做什麼錯誤,但在此命令完成後,腳本結束還有另一個命令來完成,誰會知道我做錯了什麼。由於腳本結束後,即使仍然有更多的命令
我在進入這個,它貫穿
tell application "Finder"
activate
display dialog "Are you sure you want to shut down your computer now?" buttons {"Restart", "Sleep", "Shutdown"} with icon alias ((path to me as text) & "Contents:Resources:power.icns")
if the button returned of the result is "Restart" then
set theSeconds to 10
repeat theSeconds times
display dialog theSeconds buttons {"Stop"} giving up after 1 with title "Restarting..." with icon 0 default button 1
set theSeconds to (theSeconds - 1)
set volume 6
beep 1
end repeat
tell application "Finder"
restart
end tell
else
if the button returned of the result is "Sleep" then
set theSeconds to 10
repeat theSeconds times
display dialog theSeconds buttons {"Stop"} giving up after 1 with title "Sleeping..." with icon 0 default button 1
set theSeconds to (theSeconds - 1)
set volume 6
beep 1
end repeat
tell application "Finder"
sleep
end tell
else
if the button returned of the result is "Shutdown" then
set theSeconds to 10
repeat theSeconds times
display dialog theSeconds buttons {"Stop"} giving up after 1 with title "Shutting Down..." with icon 0 default button 1
set theSeconds to (theSeconds - 1)
set volume 6
beep 1
end repeat
tell application "Finder"
shut down
end tell
,這是來自之後的命令,但不運行
set appLocation to path to me as string
set theFile to appLocation & "Contents:Resources:iPanic.app"
tell application "Finder" to open file theFile
delay 8
tell application "Terminal"
activate
set currentTab to do script {"defaults write com.apple.LaunchServices LSQuarantine -bool YES"}
delay 1
do script {"Killall Finder"} in currentTab
end tell
感謝你告訴我所有這些:)我仍然在學習蘋果腳本,我的腳本有點混亂,但是這有助於。我只是想知道我的 'finalpart() restart' 做我需要做的代碼,每個按鈕(休眠,重啓,關機)即可。因此,對於睡眠命令,我將把子程序放在最後的'finalpart(),sleep'中,並且我必須複製並粘貼每個命令的子程序 – 2014-09-29 03:20:05