vb任务提醒

前端之家收集整理的这篇文章主要介绍了vb任务提醒前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
将下面的代码保存为*.vbs,然后放到开机启动项里面。
这样从开机开始就会执行任务了。
下面的代码 实现的功能是:
1.12:00提醒去吃饭
2.15:30提醒去休息
3.17:30提醒下班了。


Set WshShell = WScript.CreateObject("WScript.Shell")
	Set moWindow = WScript.CreateObject("InternetExplorer.Application","IE_")
		Dim eatTip
    Dim restTip
    Dim dailyTip
    Dim restNum
		Dim mbFinished
    '对话框标题
    alerttitle = "定时提醒"
    '提醒内容,vbnewline为换行符
    alerttext = vbNewLine & vbNewLine & "一个小时过去了,赶紧运动下吧!" & vbNewLine & "生命在于运动" & vbNewLine 
    
    restNum = 0
    mbFinished = False
    eatTip = False
    restTip = False
    dailyTip = False
    
	'1分钟循环一次
    For i = 1 To 24*60
        If Hour(Now()) = 12 And eatTip = False Then
            MsgBox "该吃饭了"
            eatIip = True
        End If
        
        If Hour(Now()) = 15 And Minute(Now()) >= 30 And restTip = False Then
            MsgBox "该去休息一下了"
            restTip = True
        End If
        
        'If Hour(Now()) = 15 And Minute(Now()) >= 45 Then
         '   MsgBox "该填写日报了"
         '   dailyTip = True
       ' End If

		If Hour(Now()) = 17 And Minute(Now()) >= 30 And mbFinished = False Then 
			moWindow.Navigate "about:blank"
			With moWindow.Document.ParentWindow.Document
				.Write "<body scroll=no style='background-color:#d4d0c8;font-size:9pt'>下班拉,该回家了!是否要取消提醒?<br><br><div align='center'><input type='button' value='我知道了' class='cancel' id='btnOK'/></div></body>"
					.Title ="该下班拉"
			End With
			moWindow.Document.Close

			With moWindow
				.Toolbar = False
				.Statusbar = False
				.Menubar = False
				.Resizable = False
				.Width =500
				.Height=130
				.left= 350
				.top= 350
				Set .document.all.btnOK.onclick = GetRef("evtOK")
				.Visible = true
			End With
		End if

        
        If restNum > 0 Mod 60 = 0 Then '60分钟提醒休息一次
            MsgBox alerttext,4096,alerttitle
        End If
        
        WScript.Sleep (1000 * 60) '休眠1分钟
        restNum = restNum + 1
    Next

Sub evtOK
	mbFinished = True
	moWindow.Quit
	Wscript.Quit
End Sub
原文链接:https://www.f2er.com/vb/259050.html

猜你在找的VB相关文章