护眼弹窗小脚本:
使用方法:
复制粘贴到记事本中,点击另存为,编码格式选择ASNI,保存覆盖原文件
重命名,.txt后缀改为.vbs,双击即可运行。
set WshShell = WScript.CreateObject("WScript.Shell")
Dim worktime,alarmnum,relaxtime
Dim msg,response,mystring
style1 = vbYesNo + vbQuestion + vbDefaultButton2 '定义对话框样式
style2 = vbOKOnly + vbInformation + vbSystemModal + vbMsgBoxSetForeground
worktime = inputbox("请输入持续工作时间/min")
if isempty(worktime) then
msgbox "取消输入,退出程序"
WshShell.run "taskkill /f /im wscript.exe",0
else
if worktime = "" then
worktime = 20 '默认的持续工作时间
else
worktime = int(worktime)
end if
end if
alarmnum = inputbox("请输入提醒次数")
if isempty(alarmnum) then
msgbox "取消输入,退出程序"
WshShell.run "taskkill /f /im wscript.exe",0
else
if alarmnum = "" then
alarmnum = 25 '默认的提醒次数
else
alarmnum = int(alarmnum)
end if
end if
relaxtime = inputbox("请输入远眺时间/s")
if isempty(relaxtime) then
msgbox "取消输入,退出程序"
WshShell.run "taskkill /f /im wscript.exe",0
else
if relaxtime = "" then
relaxtime = 20 '默认的远眺时间
else
relaxtime = int(relaxtime)
end if
end if
msg = "设置为" & worktime & "-" & alarmnum & "-" & relaxtime & vbnewline & "是否开启护眼模式"
response = msgbox(msg,style1,"护眼")
if response = vbYes then '用户按下“是”按钮
mystring = "Yes" '进行某些操作
else '用户按下“否”按钮
mystring = "No" '进行某些操作
end if
if mystring = "Yes" then
' worktime = 1 '设置的持续工作时间
' alarmnum = 25 '25为提醒的次数
' relaxtime = 20 '设置的远眺时间
alerttitle = "已持续用眼" & worktime & "分钟!"
'提醒内容,vbnewline为换行符
alerttext = "远眺20s,点击确认计时开始"
for i = 1 to alarmnum
WScript.Sleep(1000*60*worktime) '每20分钟提醒一次
atext = alerttext & vbnewline & vbnewline
msgbox atext,style2,alerttitle
for j = relaxtime to 1 step -1
WshShell.popup "倒计时" & j & "s",1,"远眺时间",0
'WScript.Sleep(1000)
next
next
else
WshShell.run "taskkill /f /im wscript.exe",0
end if
结束任务小脚本:
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.echo "退出所有wscript.exe"
WshShell.run "taskkill /f /im wscript.exe",0