天天看點

一個定時重新開機關機的小程式

[size=large][color=black]姝ゅ?绋?搴???瀹??頒?瀹??堕???????蟲?哄??????浠h〃??浣???娆㈣?澶у?跺?寮哄??,????.

??寰?

灏?姝?澶??跺?版??????,淇?瀛?涓?.hta?煎?

??缁???娆?ta璇?瑷???????

<html>

<head>

<title>??Windows绯葷?璁℃?跺?ㄢ??</title>

<meta http-equiv="content-type" content="text/html;charset=gb2312">

<hta:application

id="WTimer"

maximizebutton="No"

minimizebutton="Yes"

singleinstance="Yes"

contextmenu="Yes"

sysmenu="Yes"

version="1.0"

inner

caption="Yes"

showintaskbar="Yes"

borderstyle="Normal"

applicationname="Windows Timer"

icon="TimerIco.ico"

/>

<Style type="text/css">

<!--

* { font-family:Courier New,Arial,Sans-serif;font-size:9pt; }

body { overflow-y:hidden; }

div a:link,div a:visited { text-decoration:none;color:#000 }

div a:hover { text-decoration:underline;color:#f00 }

#footerinfo { width:100%;display:table;margin-top:5px; }

#left { float:left;width:70%; }

#right { float:right;width:29%;text-align:right;margin-right:1px; }

-->

</Style>

<Script Language="JavaScript">

<!--

$bl_Sleep=false;

function getObject($obj) {

return(document.getElementById($obj));

}

String.prototype.parseInt=function() {

return(parseInt(this));

}

function getRadioVal($name) {

$oEms=document.getElementsByName($name);

for ($i=0;$i<$oEms.length;$i++) {

if ($oEms[$i].checked) { return($oEms[$i].value); }

}

}

function isDeclared($varName) {

return(typeof($varName)!="undefined");

}

function chStatus($name,$status) {

$ooEms=document.getElementsByName($name);

for ($a=0;$a<$ooEms.length;$a++) {

$ooEms[$a].disabled=$status;

}

}

function window.onload() {

$sWidth=window.screen.width;

$sHeight=window.screen.height;

$aWidth=400;

$aHeight=185;

window.resizeTo($aWidth,$aHeight);

window.moveTo(($sWidth-$aWidth)/2,($sHeight-$aHeight)/2);

document.bgColor="#d4d0c8";

getObject("StopButton").disabled=true;

getObject("left").innerHTML="??绀猴?璇烽???╂?ㄦ?寵?浣跨?ㄧ?????斤?";

}

function Timer_Quit() {

window.close();

}

function Timer_Kernel() {

if ($bl_Sleep) {

if (isDeclared($time) && isDeclared($mod_time) && isDeclared($operation)) {

if ($time>0) {

$Oper_str="";

$Hint_str="";

$Titl_str="";

if ($operation=="rWin") {

$Oper_str="<span style=\"color:red\">??绀猴?绯葷?璁℃?堕???????藉凡?????璇鋒敞??淇?瀛?锛?</span>";

}

else {

$Oper_str="<span style=\"color:red\">??绀猴?绯葷?璁℃?跺?抽?????藉凡?????璇鋒敞??淇?瀛?锛?</span>";

}

if ($mod_time=="mod_minute") {

$tMinute=($time/60).toString().parseInt();

$tSecond=$time%60;

if ($tMinute!=0) {

if ($tSecond<10) {

$tSecond="0"+$tSecond;

}

$Titl_str="?╀??堕?達?"+$tMinute+"??"+$tSecond+"绉?";

}

else {

$Titl_str="?╀??堕?達?"+$tSecond+"绉?";

}

}

else {

$Titl_str="?╀??堕?達?"+$time+"绉?";

}

getObject("left").innerHTML=$Oper_str;

document.title=$Titl_str;

$time=$time-1;

$o=setTimeout("Timer_Kernel()",1000);

}

else {

$Flag="";

if ($operation=="rWin") {

$Flag=6; //6涓洪??????浣?绯葷?

}

else {

$Flag=1; //1涓哄?抽????浣?绯葷?

}

OperateWin32($Flag);

getObject("left").innerHTML="<span style=\"color:red\">??绀猴?姝e?ㄦ?ц?棰?瀹???浣?锛?</span>";

document.title="姝e?ㄦ?ц?棰?瀹???浣?";

}

}

}

}

function Timer_Stop() {

$bl_Sleep=false;

if (isDeclared($o)) { clearTimeout($o); }

getObject("time").disabled=false;

getObject("mod_time").disabled=false;

chStatus("operation",false);

getObject("StartButton").disabled=false;

getObject("StopButton").disabled=true;

getObject("left").innerHTML="??绀猴?璇烽???╂?ㄦ?寵?浣跨?ㄧ?????斤?";

document.title="??Windows绯葷?璁℃?跺?ㄢ??";

}

function Timer_Start() {

$bl_Sleep=true;

$nowTime="";

$time=getObject("time").value;

$mod_time=getObject("mod_time").value;

$operation=getRadioVal("operation");

if (isNaN($time) || $time=="") {

alert("璇鋒?g‘璁懼??涓?涓??堕?村?鹼? ");

getObject("time").select();

return;

}

else {

$time=$time.parseInt();

if ($mod_time=="mod_minute") { $time=$time*60; }

}

getObject("time").disabled=true;

getObject("mod_time").disabled=true;

chStatus("operation",true);

getObject("StartButton").disabled=true;

getObject("StopButton").disabled=false;

Timer_Kernel();

}

function OperateWin32($DownFlag) {

$OS_Pro=GetObject("WinMgmts:{(shutdown)}//./root/cimv2").ExecQuery("select * from win32_operatingsystem where primary=true");

for ($e=new Enumerator($OS_Pro);!$e.atEnd();$e.moveNext()) {

$getProcess=$e.item()

$getProcess.win32shutdown($DownFlag);

}

}

function ResponseKeyPress() {

if (event.keyCode==13) { event.keyCode=9; }

}

//-->

</Script>

</head>

<body>

<fieldset>

<table width="100%" cellpadding="4" cellspacing="3">

<form name="form1">

<tr>

<td width="25%">璁懼???堕?達?</td>

<td width="75%"><input type="text" name="time" size="20" value="" 慰nkeypress="ResponseKeyPress()" />

<select name="mod_time">

<option value="mod_minute">????</option>

<option value="mod_second">绉???</option>

</select>

</td>

</tr>

<tr>

<td>???介???╋?</td>

<td>

<input type="radio" name="operation" value="rWin" checked="checked" />????

<input type="radio" name="operation" value="cWin" />?蟲??

</td>

</tr>

<tr>

<td colspan="2" style="text-align:right">

<input type="button" name="StartButton" value=" 搴???" 慰nclick="Timer_Start()" />

<input type="button" name="StopButton" value=" ??娑? " 慰nclick="Timer_Stop()" />

<input type="button" name="ExitButton" value=" ????" 慰nclick="Timer_Quit()" />

</td>

</tr>

</form>

</table>

</fieldset>

<div id="footerinfo">

<div id="left"></div>

<div id="right">

</div>

</div>

</body>

</html> [/color][/size]

繼續閱讀