网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 hta 定时关机重启实现代码
内容
    代码如下:
    <html>
    <head>
    <meta http-equiv=content-type content=text/html;charset=gb2312>
    <title>一个用于定时重启或关闭计算机的小工具,适用于windows 2k/xp/2003 </title>
    <hta:application
    id=wtimer
    maximizebutton=no
    minimizebutton=yes
    singleinstance=yes
    contextmenu=yes
    sysmenu=yes
    version=1.0
    innerborder=no
    caption=yes
    showintaskbar=yes
    border=normal
    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\>提示:正在执行预定操作!</span>;
    document.title=正在执行预定操作;
    }
    }
    }
    }
    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(请正确设定一个时间值! );
    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% border=1 cellpadding=4 cellspacing=3>
    <form name=form1>
    <tr>
    <td width=25%>设定时间:</td>
    <td width=75%><input type=text name=time size=20 value= onkeypress=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= 应用 onclick=timer_start() />
    <input type=button name=stopbutton value= 取消 onclick=timer_stop() />
    <input type=button name=exitbutton value= 退出 onclick=timer_quit() />
    </td>
    </tr>
    </form>
    </table>
    </fieldset>
    <div id=footerinfo>
    <div id=left></div>
    <div id=right>
    作者:黑虾
    </div>
    </div>
    </body>
    </html>
    如果保存后发现不能运行一般是编码的问题,可以用记事本保存
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/17 16:27:22