使用AppleScript进行定时提醒
本帖最后由 goldli 于 2019-10-3 11:28 编辑先上代码
global f1, f2, f3, f4
on run
set f1 to "/System/Library/Sounds/Pop.aiff"
set f2 to "/System/Library/Sounds/Ping.aiff"
set f3 to "/System/Library/Sounds/Glass.aiff"
set f4 to "/System/Library/Sounds/Tink.aiff"
end run
on idle
set {hours:h, minutes:m, seconds:s} to current date
if (h = 6) and (m = 30) and (s = 0) then --6:30 起床
OnAlert(f1, f4, f3, "06:30 了,快点起床。", "起床提醒.", "Hurry up , it's time to get up")
else if (h = 10) and (m = 0) and (s = 0) then --10 运动
OnAlert(f1, f4, f3, "10:00 了,新一轮的健身开始了", "健身提醒.", "start a new round of fitness")
else if (h = 12) and (m = 0) and (s = 0) then --午餐,休息,运动
OnAlert(f1, f4, f3, "12:00 了,可以准备午餐了", "午餐提醒.", "Let's prepare lunch.")
else if (h = 14) and (m = 0) and (s = 0) then --下午学习
OnAlert(f1, f4, f3, "14:00 了,午后学习开始了", "学习提醒.", "Let's start our afternoon study.")
else if (h = 17) and (m = 30) and (s = 0) then --17:30 晚餐,休息
OnAlert(f1, f4, f3, "17:30 了,可以准备晚餐了", "晚餐提醒.", "Let's prepare dinner.")
else if (h = 19) and (m = 0) and (s = 0) then --学习
OnAlert(f1, f4, f3, "19:00 了,晚上学习开始了。 ", "学习提醒.", "Let's begin our everning study.")
else if (h = 21) and (m = 0) and (s = 0) then --运动
OnAlert(f1, f4, f3, " 21:00 了,最后一次健身运动开始了。 ", "健身提醒.", "Let's start the final fitness.!")
else if (h > 23) and (m = 0) and (s = 0) then
display dialog "很晚了,睡觉吧。身体是革命的本钱,不要过度浪费啊。"
--exit repeat
end if
return 0.5
end idle
on OnAlert(sound1, sound2, sound3, content, sub, sayText)
repeat with i from 1 to 5
do shell script "afplay" & sound1
do shell script "afplay" & sound2
end repeat
do shell script "afplay" & sound3
display notification content with title "日程表" subtitle sub sound name "Ping"
say sayText
end OnAlert
使用方法
1.打开 script editor ,粘贴进去
2.导出为 application
3. 在用户,登录项 中添加
------------------------------------------------------------------------------------------------------------------------
更新,解决,app上右键选择“退出” 去无法退出程序的问题。
呵呵,有意思 先收藏,有空学习 马克马克 windows用不了吧 Sync 发表于 2019-9-14 20:24
windows用不了吧
是的,不过原理差不多,你自己写一个呗 叶落墨兮 发表于 2019-9-14 21:41
是的,不过原理差不多,你自己写一个呗
俺不会 就随便问问 看着不想win下用的 嘿嘿 支持下 感谢ing~~~~~~~~~~~~~~~~~~~~~~~~
页:
[1]