核心功能 - 自动桌面提示
这个脚本会自动触发windows桌面通知,提示重要事项,比如说:您已工作两小时,该休息了
我们可以设定固定时间提示,比如隔10分钟、1小时等
用到的第三方库:
实现代码 英文版
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
36
37
38
39
40
41
42
43
44
45
|
from win10toast import ToastNotifier
import time
toaster = ToastNotifier()
header = input("What You Want Me To Remember\n")
text = input("Releated Message\n")
time_min=float(input("In how many minutes?\n"))
time_min = time_min * 60
print("Setting up reminder..")
time.sleep(2)
print("all set!")
time.sleep(time_min)
toaster.show_toast(f"{header}", f"{text}", duration=10, threaded=True)
while toaster.notification_active(): time.sleep(0.005)
|
代码使用 中文版
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#定时通知脚本
from win10toast import ToastNotifier
import time
#构建通知对象实例
toaster = ToastNotifier()
title = input("请输入事件标题:")
content = input("请输入事件提要")
time_min = float(input("请输入提醒时间(分钟):"))
#time_min = time_min * 60
print("设置完成!")
time.sleep(1)
print("开始运行..")
time.sleep(time_min)
toaster.show_toast(f"{title}", f"{content}", duration=10, threaded=True)
while toaster.notification_active(): time.sleep(0.005)
|