KangQingYu
Articles61
Tags21
Categories9
记忆曲线复习-appleScript脚本应用

记忆曲线复习-appleScript脚本应用

如何用脚本生成在指定时间需要复习的任务?

需求

新学的东西,需要在间隔1,2,4,7,15天时复习。
以前我是用故宫日历。

近期要去几个城市,在路上的时间长,带几个本子不方便。想充分利用iCloud的同步特性。
如果手动输入6次复习时间至Fantastical2,也不是不行,但毕竟是手动的,无论是效率还是准确率都无法达到完美。

因此决定用AppleScript尝试一下。

设计思路

首次复习设为当天晚上8点。

实现代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
tell application "Reminders"
#选择默认的list
tell default list
# 获取当前时间
set theCurrentDate to current date
# 把初始时间改为当天晚上8点左右
set fromDate to theCurrentDate + 0 * days + 1 * minutes + 3 * hours
set endDate to fromDate + 5 * minutes
# 第一次间隔1天
set from2 to fromDate + 1 * days

# 第2次间隔2天
set from3 to fromDate + (1 + 2) * days

# 第3次间隔4天
set from4 to fromDate + (1 + 2 + 4) * days

set from5 to fromDate + (1 + 2 + 4 + 7) * days

set from6 to fromDate + (1 + 2 + 4 + 7 + 15) * days

set descript to "oc04-arc"
# 字符串拼接使用&
set descript15 to descript & "15"

make new reminder with properties {name:descript, due date:fromDate}
make new reminder with properties {name:descript, due date:from2}
make new reminder with properties {name:descript, due date:from3}
make new reminder with properties {name:descript, due date:from4}
make new reminder with properties {name:descript, due date:from5}
make new reminder with properties {name:descript15, due date:from6}

end tell
end tell

效果

如图是执行脚本之后,自动生成的计划。
图中的oc01, jz01是我上个月手动加的。

image.png

todo

首次复习设为当天晚上8点。期望是取今天的日期,并设时间为20:00。
但是目前只能用 current date。包含了时分秒,不知道怎么把时、分删除。
查了script的语法,只能取其字符串,但是这样就无法+1天操作了。
于是就用当前的时间,计算+几个小时,获得当天晚上8点的时间。

Author:KangQingYu
Link:http://example.com/2021/04/04/20210404_appleScript%E8%84%9A%E6%9C%AC%E5%BA%94%E7%94%A8-%E8%AE%B0%E5%BF%86%E6%9B%B2%E7%BA%BF%E5%A4%8D%E4%B9%A0/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可
×