How to Make a VBScript Timer -
i need have timer appear in message box, coded in vbs. message box needs in bottom left corner of screen, above start menu. needs not able exit, meaning cannot listed on task bar (hopefully) , have no minimise/exit buttons. needs stay on top of other windows. needs start @ 20 minutes, counting down in seconds. hope can me - it's computer lab.
thanks, matthew
try :
option explicit dim title,ws,nminutes,nseconds,smessage title = "counting down shutdown" set ws = createobject("wscript.shell") nminutes = 20 nseconds = 0 smessage = "<font color=red size=2><b>counting down shutdown" 'open chromeless window message htabox("lightblue",100,250,0,630) .document.title = "counting down notification shutdown" .msg.innerhtml = smessage until .done.value or (nminutes + nseconds < 1) .msg.innerhtml = smessage & "<br>" & nminutes & ":" & right("0"&nseconds, 2) _ & " remaining</b></font><br>" wsh.sleep 1000 ' milliseconds nseconds = nseconds - 1 if nseconds < 0 if nminutes > 0 nminutes = nminutes - 1 nseconds = 59 end if end if loop .done.value = true .close end ws.popup "time on !","5",title,0+48 'afficher un popup durant 5 secondes puis on quitte le script 'command="cmd /c shutdown.exe -s -t 30 -c " & dblquote("sauvegarder votre travail car l'ordinateur va rebooter dans 30 secondes") 'executer = ws.run(command,0,false) '***************************************************************** function htabox(sbgcolor, h, w, l, t) dim ie, hta, scmd, nrnd randomize : nrnd = int(1000000 * rnd) scmd = "mshta.exe ""javascript:{new " _ & "activexobject(""internetexplorer.application"")" _ & ".putproperty('" & nrnd & "',window);" _ & "window.resizeto(" & w & "," & h & ");" _ & "window.moveto(" & l & "," & t & ")}""" createobject("wscript.shell") .run scmd, 1, false until .appactivate("javascript:{new ") : wsh.sleep 10 : loop end 'wshshell each ie in createobject("shell.application").windows if isobject(ie.getproperty(nrnd)) set htabox = ie.getproperty(nrnd) ie.quit htabox.document.title = "htabox" htabox.document.write _ "<hta:application contextmenu=no border=thin " _ & "minimizebutton=no maximizebutton=no sysmenu=no showintaskbar=no >" _ & "<body scroll=no style='background-color:" _ & sbgcolor & ";font:normal 10pt arial;" _ & "border-style:inset;border-width:3px'" _ & "onbeforeunload='vbscript:if not done.value " _ & "window.event.cancelbubble=true:" _ & "window.event.returnvalue=false:" _ & "done.value=true:end if'>" _ & "<input type=hidden id=done value=false>" _ & "<center><span id=msg> </span><br>" _ & "<input type=button id=btn1 value=' ok ' "_ & "onclick=done.value=true><center></body>" htabox.btn1.focus exit function end if next msgbox "hta window not found." wsh.quit end function '*****************************************************************
Comments
Post a Comment