

PLUS练习
import win.ui;
import sys;
import time.ole;
/*DSG{{*/
mainForm = ..win.form(text="天天定时关机";right=447;bottom=175;bgcolor=4670273;border="none";exmode="none")
mainForm.add(
button={cls="button";text="执行";left=352;top=80;right=424;bottom=112;z=2};
button2={cls="button";text="取消";left=352;top=128;right=424;bottom=160;z=10};
combobox={cls="combobox";text="combobox";left=216;top=72;right=272;bottom=96;bgcolor=0;color=15793151;edge=1;items={};mode="dropdown";vscroll=1;z=6};
combobox2={cls="combobox";text="combobox2";left=280;top=72;right=336;bottom=96;edge=1;items={};mode="dropdown";vscroll=1;z=7};
combobox3={cls="combobox";text="combobox3";left=352;top=40;right=424;bottom=60;edge=1;items={};mode="dropdown";vscroll=1;z=9};
datetimepick={cls="datetimepick";left=104;top=72;right=208;bottom=96;edge=1;z=3};
plus={cls="plus";right=448;bottom=32;background="\res\层_1.png";left=0;top=0;z=1};
plus3={cls="plus";top=8;right=80;bottom=24;background="\res\层_3.png";left=0;repeat="scale";z=13};
plusMax={cls="plus";left=416;top=8;right=432;bottom=24;background="\res\层_5.png";clipch=1;notify=1;repeat="scale";transparent=1;z=12};
plushit={cls="plus";left=392;top=8;right=407;bottom=24;background="\res\层_8.png";notify=1;repeat="scale";transparent=1;z=11};
static={cls="static";text="static";left=16;top=40;right=280;bottom=56;color=13421772;transparent=1;z=4};
static2={cls="static";text="需执行的时间:";left=16;top=80;right=104;bottom=104;color=13092807;transparent=1;z=5};
static3={cls="static";text="请先选择执行内容";left=16;top=120;right=279;bottom=160;color=12632256;transparent=1;z=8};
static4={cls="static";text="执行内容:";left=288;top=40;right=376;bottom=56;color=13421772;transparent=1;z=14}
)
/*}}*/
//最小化按钮
mainForm.plushit.oncommand = function(id,event){
mainForm.hitmin()
}
//关闭按钮
mainForm.plusMax.oncommand = function(id,event){
mainForm.close()
}
mainForm.plushit.skin(
background = {
hover = "/res/层_7.png";
active = "/res/层_6.png";
default="/res/层_8.png";
}
)
mainForm.plusMax.skin(
background = {
hover = "/res/层_4.png";
active = "/res/层_2.png";
default="/res/层_5.png";
}
)
for(i=1;24;1){//给小时赋值
if(i<10){
i="0"++tostring(i);
}
mainForm.combobox.add(tostring(i));
}
for(i=1;60;1){//给分钟赋值
if(i<10){
i="0"++tostring(i);
}
mainForm.combobox2.add(tostring(i));
}
mainForm.combobox3.add("关机");
mainForm.combobox3.add("重启");
mainForm.combobox3.add("注销");
mainForm.combobox3.add("待机");
mainForm.combobox3.add("休眠");
mainForm.combobox3.add("锁定计算机");
tmid = mainForm.addtimer(//检测当前时间
1000/*毫秒*/,
function(hwnd,msg,id,tick){//定时执行代码
tm=time.ole(__,"%Y-%m-%d %H:%M:%S")
mainForm.static.text="系统当前时间:"++tostring(tm)
}
);
mainForm.button.oncommand = function(id,event){//确认执行时间
mainForm.button.disabled=true;
bd=mainForm.datetimepick.text++" "++mainForm.combobox.selText++":"++mainForm.combobox2.selText++":"++"00"
mainForm.static3.text="执行操作时间:"++bd
tmid1 = mainForm.addtimer(
1000/*毫秒*/,
function(hwnd,msg,id,tick){//定时执行代码
if(tostring(tm)=bd){
select(mainForm.combobox3.selText) {
case "关机" {
sys.shutdown()//关机
}
case "重启"{
sys.restart()//重启
}
case "注销"{
sys.logoff()//注销
}
case "待机"{
sys.standby()//待机
}
case "休眠"{
sys.sleep()//休眠
}
case "锁定计算机"{
sys.lock()//锁定计算机
}
}
}
}
);
}
mainForm.button2.oncommand = function(id,event){
//mainForm.msgbox( mainForm.button2.text );
bd=0;
mainForm.static3.text="已取消操作!"
mainForm.button.disabled=false;
}
/***
import config;
mainForm.bindConfig( config.mainForm,{
edit = "text"; //绑定edit控件的text属性值到配置文件
radiobutton = "checked";
checkbox = "checked";
combobox = "selIndex";
} );
***/
mainForm.wndproc = {
[ 0x201/*_WM_LBUTTONDOWN*/ ] = function(hwnd,message,wParam,lParam){
mainForm.hitCaption();
}
}
//创建圆角窗体
import win.region.round;
win.region.round(mainForm)
mainForm.show()
win.loopMessage();