打卡下班小助手(VBS)
代码为本人原创,转载请标明来源。
'来源:https://a-learner.com/blog/app/clock_out_assistant(VBS)
'作者:zll
Dim input
Function to_str(a)
If a<10 Then
to_str="0"&cstr(a)
Else
to_str=cstr(a)
End If
End Function
Function add(a,b,c)
h=hour(now)+a
m=minute(now)+b
s=second(now)+c
Do While s>=60
s=s-60
m=m+1
Loop
Do While m>=60
m=m-60
h=h+1
Loop
Do While h>=24
h=h-24
Loop
add=(h=Cint(input(0)))and(m=Cint(input(1)))and(s=Cint(input(2)))
End Function
Function try()
If add(0,0,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"现在是打卡下班时间,我们下班了!"
try=1
ElseIf add(0,1,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 1 分钟打卡下班。"
ElseIf add(0,2,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 2 分钟打卡下班。"
ElseIf add(0,3,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 3 分钟打卡下班。"
ElseIf add(0,4,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 4 分钟打卡下班。"
ElseIf add(0,5,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 5 分钟打卡下班。"
ElseIf add(0,10,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 10 分钟打卡下班。"
ElseIf add(0,15,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 15 分钟打卡下班。"
ElseIf add(0,30,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 30 分钟打卡下班。"
ElseIf add(1,0,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 1 小时打卡下班。"
ElseIf add(1,30,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 1 小时 30 分钟打卡下班。"
ElseIf add(2,0,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 2 小时打卡下班。"
ElseIf add(2,30,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 2 小时 30 分钟打卡下班。"
ElseIf add(3,0,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 3 小时打卡下班。"
ElseIf add(4,0,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 4 小时打卡下班。"
ElseIf add(5,0,0) Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"还有 5 小时打卡下班。"
End If
End Function
input=InputBox("请输入打卡下班的时间。格式为 hh:mm:ss,首位为 0 可省略。","打卡下班小助手","12:00:00")
if(input="") Then
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"现在退出。"
Else
input=Split(input,":")
CreateObject("SAPI.SpVoice").speak"我是打卡下班小助手。"
CreateObject("SAPI.SpVoice").speak"欢迎使用。"
Do
WScript.Sleep 300
Loop while try()<>1
End If