我正在尝试自动关闭我的 Mac,我已经尝试了节能器中的计划关机,我想 sleep ,但这些似乎不起作用。 VLC 播放器 runnign 似乎可以防止关机。我想我需要一个脚本来强制关闭 mac,而不管运行的各种程序可能会向屏幕抛出什么错误。
谢谢
好的,
这是我用来关闭 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
最佳答案
你能试试一个简单的 applescript,它是这样的......
tell application "System Events"
shut down
end tell
看看它是否有效,然后你可以让它在特定时间通过 Automator 运行,等等。
https://stackoverflow.com/questions/5565659/