我心里有这样的想法,每天早上,当我第一次打开电脑时,除了第一天之外的所有程序都会关闭,这样我就可以每天第一件事就开始写日记,而不会受到任何干扰。
我认为使用 AppleScript 和 Automator(可能还有其他一些东西)的组合应该可以实现,但我对 Mac 世界还很陌生,所以我需要一点帮助。
下面是一些伪代码,展示了我的想法;
on wakeup, if time is between 6am and 8:30am
quit all apps except Day One
start Day One
end if
很简单,但我不知道在哪里编写脚本或如何编写。
答案1
我安装了睡眠观察者通过 MacPorts 并将其设置为在唤醒时运行以下 AppleScript;
if hours of the (current date) is greater than 6 then if hours of the (current date) is less than 9 then
tell application "System Events"
set theResults to get buttons of (windows of (application processes whose visible is true)) whose description is "close button" -- a list of visible applications, containing a list of windows, containing a list of (one) buttons
repeat with anApp in theResults
if contents of anApp is not in {} then -- windows are open
repeat with eachWindow in (items of anApp)
click first item of eachWindow -- only the one minimize button
end repeat
end if
end repeat
end tell
tell application "Day One" to activate
end if
如果唤醒脚本激活的时间在早上 6 点到 8 点之间,它会关闭所有打开的窗口并启动 Day One。