这篇稿子写出来过后自我感觉界面还可以,效果还不错
1、可以在界面中随时更改关机的时间。
2、关掉程序即取消定时关机。
3、默认以分钟数作为关机时间,如果输入冒号,则把冒号前面的作为小时数处理。
4、可以兼容以全角输入的数字和冒号。
但是有个问题没解决是:弹出的提示框未处于被聚焦状态,需要鼠标定位点击后才能输入,请知道的指点一下解决方法。- '直接输入数字就是按所输入数字的分钟数后关机
- '如果用冒号隔开则把小时和分钟一起计算
- '可以随时更改关机时间
- Dim WshShell,ip,Net_test,addr,str,i,count,speed
- Set WshShell=CreateObject("shell.application")
- WshShell.MinimizeAll
- Set WshShell=createobject("wscript.shell")
-
- Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
- set ie=wscript.createobject("internetexplorer.application","event_") '创建ie对象'
- ie.fullscreen=0 '不使用全屏
- ie.menubar=0 '取消菜单栏'
- ie.addressbar=0 '取消地址栏'
- ie.toolbar=0 '取消工具栏'
- ie.statusbar=0 '取消状态栏'
- ie.width=450 '宽'
- ie.height=435 '高'
- ie.resizable=0 '不允许用户改变窗口大小'
- ie.navigate "about:blank" '打开空白页面'
- 'ie.left=fix(ie.document.parentwindow.screen.availwidth-ie.width/2) '水平居中'
- ie.top=10
- ie.visible=0
- ie.visible=0 '窗口不可见'
- with ie.document '以下调用document.write方法,'
- .write "<html><head><title>简易自定义关机程序</title></head><body bgcolor=#dddddd scroll=no>"
- .write "<br><font size=5><center><font face=黑体>九洲系统优化系列 </font></center><br></font>"
- .write string(6," ") & "功能建议和信息反馈请点击:<a href=http://bbs.dp168.com/thread-88488-1-1.html target=_blank>东坡论坛"
- .write "</a></font></p><br> 请输入多久后关机:"
- .write "<input id=time_in type=text size=5 name=time_in onkeydown="& chr(34) & "if(event.keyCode==13) document.all.confirm.focus();" & chr(34) & ">"
- .write " 还剩下:<label id=time_echo type=text size=5 name=time_echo>"
- .write "</label><br><br><p align=right><label id=time_demo type=text size=5 name=time_demo> </label>"
- .write "<input id=cancel type=button value=退出> <input id=confirm type=button value=确定 onclick=confirm>"
- .write " <p>"
- .write "<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=417 height=156 "
- .write "codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab>"
- .write "<param name=movie value=http://dp168.com/ad/clock.swf>"
- .write "<param name=quality value=high><param name=bgcolor value=#869ca7>"
- .write "<param name=allowScriptAccess value=always><embed src="
- .write "http://dp168.com/ad/clock.swf quality=high "
- .write "name=Timer align=middle width=417 height=156 play=true loop=false allowScriptAccess=always "
- .write "type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer>"
- .write "</embed></object></font></body></html><!-- document.all.time_in.focus(); --> "
- end with
- dim wmi '显式定义一个全局变量'
- set wnd=ie.document.parentwindow '设置wnd为窗口对象'
- set id=ie.document.all '设置id为document中全部对象的集合'
- id.confirm.onclick=getref("confirm") '设置点击"确定"按钮时的处理函数'
- id.cancel.onclick=getref("cancel") '设置点击"取消"按钮时的处理函数'
- tmp_mi=0
- tmp=0
- tmp_sec=0
- wscript.sleep 200
- ie.visible=1 '窗口可见'
- 'ie.document.username.focus()
- 'ie.document.getElementById("username").focus()
-
-
-
-
-
-
-
-
- do while true '由于ie对象支持事件,所以相应的,'
- wscript.sleep 1000 '脚本以无限循环来等待各种事件。'
- 'msgbox "H" & IE.document.GetElementById("time_echo").innerHTML & "H"
- if tmp_mi>=0 and tmp_sec>0 then
- tmp_sec=tmp_sec-1
- if tmp_sec<1 then
- tmp_sec=60
- tmp_mi=tmp_mi-1
- end if
- tmp_h=int(tmp_mi/60):if tmp_h>0 then tmp_h=tmp_h & "小时" & tmp_mi-tmp_h*60 else tmp_h=tmp_mi
- if tmp_mi>-1 then IE.document.GetElementById("time_echo").innerHTML=tmp_h & ":" & tmp_sec
- end if
- if tmp_mi<0 and tmp_sec=60 then Shutdown()
- loop
- sub event_onquit 'ie退出事件处理过程'
- wscript.quit '当ie退出时,脚本也退出'
- end sub
- sub cancel '"取消"事件处理过程'
- ie.quit '调用ie的quit方法,关闭IE窗口'
- end sub '随后会触发event_onquit,于是脚本也退出了'
- sub confirm '"确定"事件处理过程,这是关键'
- with id
- tmp=.time_in.value
- if tmp>"" then tmp=Num(tmp)
- if instr(tmp,":") then tmp_left=left(tmp,instr(tmp,":")-1):tmp_right=right(tmp,len(tmp)-instr(tmp,":")):tmp=tmp_left*60+tmp_right
- if isnumeric(tmp) then if tmp<1 then tmp=""
- if isnumeric(tmp)=false then tmp=""
- if tmp="" then
- IE.document.GetElementById("time_demo").innerHTML= "<font color=red>请输入正确的分钟数!</font>"
- tmp=0
- .time_in.value="" '空值则默认
- else
- tmp_mi=tmp-1:tmp_sec=60
- IE.document.GetElementById("time_demo").innerHTML= ""
- end if
- end with
- end sub
-
- '===========================================================================================
- Function Shutdown() '关机
- Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")
- For Each objOperatingSystem in colOperatingSystems
- ObjOperatingSystem.Win32Shutdown(8)
- Next
- End Function
-
- Function Num(i) '转换中文
- k=""
- for j=1 to len(i)
- l=mid(i,j,1)
- if l="1" then l="1"
- if l="2" then l="2"
- if l="3" then l="3"
- if l="4" then l="4"
- if l="5" then l="5"
- if l="6" then l="6"
- if l="7" then l="7"
- if l="8" then l="8"
- if l="9" then l="9"
- if l="0" then l="0"
- if l=":" then l=":"
- k=k & l
- next
- Num=k
- End Function
复制代码
|