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

RT2018 2019-08-12 18:14:00
原文地址:https://www.cnblogs.com/RT2018/p/11341729.html

番茄工作法:

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

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

声明:该文章系转载,转载该文章的目的在于更广泛的传递信息,并不代表本网站赞同其观点,文章内容仅供参考。

本站是一个个人学习和交流平台,网站上部分文章为网站管理员和网友从相关媒体转载而来,并不用于任何商业目的,内容为作者个人观点, 并不代表本网站赞同其观点和对其真实性负责。

我们已经尽可能的对作者和来源进行了通告,但是可能由于能力有限或疏忽,导致作者和来源有误,亦可能您并不期望您的作品在我们的网站上发布。我们为这些问题向您致歉,如果您在我站上发现此类问题,请及时联系我们,我们将根据您的要求,立即更正或者删除有关内容。本站拥有对此声明的最终解释权。