【发布时间】:2011-07-30 18:07:49
【问题描述】:
我正在尝试自动关闭我的 mac,我已尝试在节能器中按计划关机,我想睡觉,但这些似乎不起作用。 VLC player runnign 似乎可以防止关机。我想我需要一个脚本来强制关闭 mac,不管运行的各种程序可能会抛出什么错误。
谢谢
好的,
这是我用来关闭may mac的applescript代码。我已将其添加为每晚运行的 iCal 活动。
tell application "System Events" to set the visible of every process to true
set white_list to {"Finder"}
try
tell application "Finder"
set process_list to the name of every process whose visible is true
end tell
repeat with i from 1 to (number of items in process_list)
set this_process to item i of the process_list
if this_process is not in white_list then
do shell script "killall \"" & this_process & "\""
end if
end repeat
on error
tell the current application to display dialog "An error has occurred!" & return & "This script will now quit" buttons {"Quit"} default button 1 with icon 0
end try
tell application "System Events"
shut down
end tell
【问题讨论】:
标签: macos osx-snow-leopard applescript