用vbs脚本简易实现 番茄工作法

番茄工作法:

专注于某一段时间,减少打断,提高时间的感知和掌控。

25min工作+5min休息

 

周期:4x(25+5)+20

 VBS代码实现如下:

 1 Dim fso,f,count,time,shell
 2 set fso=wscript.CreateObject("Scripting.FileSystemObject")
 3 set f=fso.opentextfile("d:\test.txt",8,true)
 4 Set shell = CreateObject("Shell.Application")
 5 count = 1
 6 for j = 1 to 3
 7 for i = 1 to 4
 8 time = Now
 9 shell.ToggleDesktop
10 CreateObject("SAPI.SpVoice").Speak  "开始持续25分钟集中注意力"
11 MsgBox "hello,Start focusing in 25 minutes"
12 f.Write("Number of tasks started: ")
13 f.WriteLine(count)
14 f.WriteLine("Start focusing in 25 minutes at ")
15 f.WriteLine(time)
16 wscript.sleep 1000*60*25
17 time = Now
18 shell.ToggleDesktop
19 CreateObject("SAPI.SpVoice").Speak  "集中注意力时间结束,开始持续5分钟休息"
20 MsgBox "hello,Start resting in 5 minutes"
21 f.WriteLine("Start resting in 5 minutes at ")
22 f.WriteLine(time)
23 f.WriteBlankLines(1)
24 count=count+1
25 wscript.sleep 1000*60*5
26 next
27 time = Now
28 shell.ToggleDesktop
29 CreateObject("SAPI.SpVoice").Speak  "4次番茄工作法循环结束,开始持续20分钟休息"
30 MsgBox "hello,4 times tomato work method end"
31 f.WriteBlankLines(1)
32 f.Write("Number of tasks started: ")
33 f.WriteLine(j)
34 f.WriteLine("Start resting after 4 times tomato work method at ")
35 f.WriteLine(time)
36 wscript.sleep 1000*60*20
37 next
38 f.Close()
39 set f = nothing
40 set fso = nothing

 

为适应强迫症增加vds定时器调用如下:

 1 Include "D:\test.vbs"
 2  
 3 Sub Include(sInstFile) 
 4     Dim oFSO, f, s, w, time
 5     Set oFSO = CreateObject("Scripting.FileSystemObject") 
 6     Set f = oFSO.OpenTextFile(sInstFile) 
 7     Set w = oFSO.opentextfile("d:\timing.txt",8,true)
 8     count = 1
 9     'wscript.sleep 1000*60*14
10     time = Now
11     MsgBox "hello,Start resting in 5 minutes"
12     CreateObject("SAPI.SpVoice").Speak  "集中注意力时间结束,开始持续5分钟休息"
13     w.Write("Number of tasks started: ")
14     w.WriteLine(count)
15     w.WriteLine("Start resting in 5 minutes at ")
16     w.WriteLine(time)
17     count=count+1
18     wscript.sleep 1000*60*3
19     s = f.ReadAll 
20     f.Close 
21     Set f = Nothing
22     Set oFSO = Nothing
23     ExecuteGlobal s 
24     set w = nothing
25 End Sub

 

posted @ 2019-08-12 18:14  RT2018  阅读(434)  评论(0编辑  收藏  举报