|
自动监控 注册修改 防止软件过期
import win.ui;
/*DSG{{*/
mainForm = win.form(text="同步监测";right=751;bottom=311)
mainForm.add(
HourCBX={cls="combobox";left=112;top=136;right=153;bottom=156;edge=1;items={"00";"01";"02";"03";"04";"05";"06";"07";"08";"09";"10";"11";"12";"13";"14";"15";"16";"17";"18";"19";"20";"21";"22";"23"};mode="dropdown";vscroll=1;z=6};
MinutesCBX={cls="combobox";left=168;top=136;right=209;bottom=156;edge=1;items={"00";"01";"02";"03";"04";"05";"06";"07";"08";"09";"10";"11";"12";"13";"14";"15";"16";"17";"18";"19";"20";"21";"22";"23";"24";"25";"26";"27";"28";"29";"30";"31";"32";"33";"34";"35";"36";"37";"38";"39";"40";"41";"42";"43";"44";"45";"46";"47";"48";"49";"50";"51";"52";"53";"54";"55";"56";"57";"58";"59"};mode="dropdown";vscroll=1;z=9};
NowTime={cls="static";left=416;top=104;right=704;bottom=128;transparent=1;z=14};
Show={cls="static";text="执行时间:";left=384;top=128;right=672;bottom=184;bgcolor=15780518;border=1;edge=1;notify=1;z=13};
WeekCHlist={cls="checklist";left=248;top=160;right=344;bottom=296;ah=1;aw=1;edge=1;items={"星期一";"星期二";"星期三";"星期四";"星期五";"星期六";"星期日"};vscroll=1;z=5};
allCheck={cls="button";text="全选";left=248;top=128;right=280;bottom=152;z=11};
colorBlock={cls="static";left=168;top=40;right=200;bottom=71;bgcolor=65535;color=-1;notify=1;z=1};
inverse={cls="button";text="反选";left=296;top=128;right=328;bottom=152;z=12};
pauseBtn={cls="button";text="暂停";left=400;top=40;right=474;bottom=80;disabled=1;z=3};
starBtn={cls="button";text="开始";left=256;top=40;right=330;bottom=80;bgcolor=65535;z=2};
static2={cls="static";text="下次执行时间:";left=16;top=136;right=96;bottom=168;align="right";transparent=1;z=7};
static3={cls="static";text="时";left=152;top=136;right=185;bottom=155;transparent=1;z=8};
static4={cls="static";text="分";left=216;top=136;right=244;bottom=159;transparent=1;z=10};
stopBtn={cls="button";text="停止";left=528;top=40;right=602;bottom=80;disabled=1;z=4};
todayChBox={cls="checkbox";text="当天开始";left=48;top=64;right=136;bottom=80;z=15};
tomorrowChBox={cls="checkbox";text="第二天开始";left=48;top=40;right=136;bottom=56;checked=1;z=16;false}
)
/*}}*/
mainForm.NowTime.text="现在时间:"
+tostring(time().year)+"年"
+tostring(time().month)+"月"
+tostring(time().day)+"日"
+" "
+tostring(time().hour)
+":"
+tostring(time().minute)
+":"
+tostring(time().second);
var bgflag=false;
var BntFlag=false;
var NowtimeStr="";
var timeStr="";
var CountNuber=0;
mainForm.starBtn.oncommand = function(id,event){
if(#timeStr>0){
tmId = mainForm.setInterval(
250,
function(hwnd,msg,id,tick){
if(bgflag==false){
mainForm.colorBlock.bgcolor=0xFFFFFFFF;
bgflag=true;
}
else{
mainForm.colorBlock.bgcolor=65535;
bgflag=false;
}
mainForm.colorBlock.redraw()
NowtimeStr=tostring(time().year)+"年"
+tostring(time().month)+"月"
+tostring(time().day)+"日"
+" "
+tostring(time().hour)
+":"
+tostring(time().minute)
+":"
+tostring(time().second);
mainForm.NowTime.text="现在时间: "
+NowtimeStr;
if(timeStr==NowtimeStr){
//mainForm.msgbox("执行中");
CountNuber=CountNuber+1;
change();
regChange();
CountNuber=0;
}
// return 250; //将时间间隔修改为250
}
)
mainForm.starBtn.disabled=1
mainForm.pauseBtn.disabled=0
mainForm.stopBtn.disabled=0
}
else{
mainForm.msgbox("请配置执行时间!")
}
}
mainForm.pauseBtn.oncommand = function(id,event){
if(mainForm.pauseBtn.text=="暂停"){
mainForm.changeInterval(tmId,-1);//暂停
mainForm.pauseBtn.text="继续";
}
else{
mainForm.changeInterval(tmId,250)//重新设定时间间隔
mainForm.pauseBtn.text="暂停";
}
}
mainForm.stopBtn.oncommand = function(id,event){
mainForm.clearInterval(tmId)//移除此定时器
mainForm.starBtn.disabled=0;
mainForm.pauseBtn.disabled=1;
mainForm.stopBtn.disabled=1;
}
mainForm.allCheck.oncommand = function(id,event){
BntFlag=true;
for (i = 1; mainForm.WeekCHlist.count;1) {
mainForm.WeekCHlist.setChecked(i,true);
}
timeStr=tostring(time().year)+"年"
+tostring(time().month)+"月"
+tostring(time().day+1)+"日"
+" "
+mainForm.HourCBX.text
+":"
+mainForm.MinutesCBX.text
+":0"
mainForm.Show.text="下次执行时间: "
+timeStr
+'\r\n'
+'\r\n'
+"每天执行";
;
BntFlag=false;
}
mainForm.inverse.oncommand = function(id,event){
BntFlag=true;
var tarr = {};
var n=0;
var s="";
for (i = 1; mainForm.WeekCHlist.count) {
if(mainForm.WeekCHlist.getChecked(i)==true){
mainForm.WeekCHlist.setChecked(i,false)
}
else{
mainForm.WeekCHlist.setChecked(i,true);
if(#s>0){
s= s +", " +mainForm.WeekCHlist.getItemText(i);
}
else{
s= mainForm.WeekCHlist.getItemText(i);
}
table.push(tarr,i);
n=n+1;
}
}
if(n>0){
chaWeekDay=difWeekDay(tarr);
check(n,s,chaWeekDay);
}
if(n==0){
timeStr="";
mainForm.Show.text="下次执行时间: ";
}
BntFlag=false;
//mainForm.msgbox(tostring(time().dayofweek));
}
mainForm.WeekCHlist.onnotify = function(id,code,ptr){
if(BntFlag==false){
var tarr = {};
var n=0;
var s="";
var m=0;
if( code == 0xFFFFFF9B/*_LVN_ITEMCHANGED*/ ){
for (i = 1; mainForm.WeekCHlist.count) {
if(mainForm.WeekCHlist.getChecked(i)==true){
if(#s>0){
s= s +", " +mainForm.WeekCHlist.getItemText(i);
}
else{
s= mainForm.WeekCHlist.getItemText(i);
}
//table.insert(tarr,i);
table.push(tarr,i);
n=n+1;
}else {
m=m+1;
}
}
}
//win.msgbox(n);
if(n>0){
chaWeekDay=difWeekDay(tarr);
check(n,s,chaWeekDay);
}
if(n==0 and m==7){
timeStr="";
mainForm.Show.text="下次执行时间: ";
}
n=0;
s="";
m=0;
}
}
function difWeekDay(tarr){
var NowWeekDay=time().dayofweek;
var chaDay=0;
if(mainForm.tomorrowChBox.checked==true){
//找是否 大于 有大于今天
for i=1;#tarr;1 {
//mainForm.msgbox("tarr[ i ]大于="+tarr[ i ] );
if(tarr[ i ]>NowWeekDay){
chaDay=tarr[ i ]-NowWeekDay;
return chaDay;
break;
}
}
//找出 相差最小的
if(chaDay=0){
var maxL=#tarr;
//mainForm.msgbox("maxL="+maxL );
for i=1;#tarr;1 {
//mainForm.msgbox("tarr[ i ]小于="+tarr[ i ] );
if(tarr[ i ]<NowWeekDay){
chaDay=7-NowWeekDay+tarr[ i ];
return chaDay;
break;
}
}
}
//找出 是否 有等于今天
if(chaDay=0){
var maxL=#tarr;
//mainForm.msgbox("maxL等于="+maxL);
for i=1;#tarr;1 {
//mainForm.msgbox("tarr[ i ]等于="+tarr[ i ]+" i="+i );
if(tarr[ i ]=NowWeekDay){
if(i<maxL){
chaDay=tarr[i+1]-tarr[ i ];
return chaDay;
break;
}
if(i=maxL){
if(maxL>=2){
chaDay=7-NowWeekDay+tarr[ i ];
return chaDay;
break;
}
if(maxL=1){
chaDay=7;
return chaDay;
break;
}
}
}
}
}
}
else{
if(CountNuber>0){
//找是否 大于 有大于今天
for i=1;#tarr;1 {
//mainForm.msgbox("tarr[ i ]大于="+tarr[ i ] );
if(tarr[ i ]>NowWeekDay){
chaDay=tarr[ i ]-NowWeekDay;
return chaDay;
break;
}
}
//找出 相差最小的
if(chaDay=0){
var maxL=#tarr;
//mainForm.msgbox("maxL="+maxL );
for i=1;#tarr;1 {
//mainForm.msgbox("tarr[ i ]小于="+tarr[ i ] );
if(tarr[ i ]<NowWeekDay){
chaDay=7-NowWeekDay+tarr[ i ];
return chaDay;
break;
}
}
}
//找出 是否 有等于今天
if(chaDay=0){
var maxL=#tarr;
//mainForm.msgbox("maxL等于="+maxL);
for i=1;#tarr;1 {
//mainForm.msgbox("tarr[ i ]等于="+tarr[ i ]+" i="+i );
if(tarr[ i ]=NowWeekDay){
if(i<maxL){
chaDay=tarr[i+1]-tarr[ i ];
return chaDay;
break;
}
if(i=maxL){
if(maxL>=2){
chaDay=7-NowWeekDay+tarr[ i ];
return chaDay;
break;
}
if(maxL=1){
chaDay=7;
return chaDay;
break;
}
}
}
}
}
}
else{
chaDay=0
return chaDay;
}
}
}
function check(n,s,c){
var tm = time.now();
tm.addday(c);
select( n ) {
case 7 {
timeStr=tostring(tm.year)+"年"
+tostring(tm.month)+"月"
+tostring(tm.day)+"日"
+" "
+mainForm.HourCBX.text
+":"
+mainForm.MinutesCBX.text
+":0";
mainForm.Show.text="下次执行时间: "
+timeStr
+'\r\n'
+'\r\n'
+"每天执行";
}
case 0{
timeStr="";
mainForm.Show.text="下次执行时间: ";
}
case >0 {
timeStr=tostring(tm.year)+"年"
+tostring(tm.month)+"月"
+tostring(tm.day)+"日"
+" "
+mainForm.HourCBX.text
+":"
+mainForm.MinutesCBX.text
+":0";
mainForm.Show.text="下次执行时间: "
+timeStr
+'\r\n'
+'\r\n'
+s
+" 执行";
}
else{ //所有条件不符时执行else语句块
}
}
}
function change(){
var tarr = {};
var n=0;
var s="";
for (i = 1; mainForm.WeekCHlist.count) {
if(mainForm.WeekCHlist.getChecked(i)==true){
if(#s>0){
s= s +", " +mainForm.WeekCHlist.getItemText(i);
}
else{
s= mainForm.WeekCHlist.getItemText(i);
}
//table.insert(tarr,i);
table.push(tarr,i);
n=n+1;
}
}
if(n>0){
chaWeekDay=difWeekDay(tarr);
check(n,s,chaWeekDay);
}
n=0;
s="";
}
mainForm.tomorrowChBox.oncommand = function(id,event){
if(mainForm.tomorrowChBox.checked==true){
mainForm.todayChBox.checked=false;
}else {
mainForm.todayChBox.checked=true;
}
change();
}
mainForm.todayChBox.oncommand = function(id,event){
if(mainForm.todayChBox.checked==true){
mainForm.tomorrowChBox.checked=false;
}else {
mainForm.tomorrowCtodayChBox=true;
}
change();
}
mainForm.HourCBX.oncommand = function(id,event){
change();
}
mainForm.MinutesCBX.oncommand = function(id,event){
change();
}
function regChange(){
var flag=false;
var reg = win.reg("HKEY_USERS\S-1-5-21-1645522239-884357618-839522115-500\Software\SuperFlexibleSynchronizer",true);
var qBin = reg.queryValue("DaysProV5"); //读取二进制字符串
if(#qBin>0)
{
reg.setSzValue("DaysProV5",""); //设置新值
var HBin = reg.queryValue("DaysProV5"); //读取二进制字符串
//mainForm.msgbox("修改DaysProV5成功");
//flag=true;
}else{
// mainForm.msgbox("没有需要修改的内容");
}
var Sreg = win.reg("HKEY_CURRENT_USER\Control Panel\Mouse",true);
var SBin = reg.queryValue("Special_Flags7"); //读取二进制字符串
if(#SBin>0)
{
reg.setSzValue("Special_Flags7",""); //设置新值
var HSBin = reg.queryValue("Special_Flags7"); //读取二进制字符串
//mainForm.msgbox("修改成功Special_Flags7");
flag=true;
}else{
//mainForm.msgbox("没有需要修改的内容");
}
if (flag=true){
//关闭退出
// 有主程序
if(process.find("SuperFlexibleSynchronizer.exe")){
//process.kill("SuperFlexibleSynchronizer.exe");
var FMHwnd= winex.findActivate("Super Flexible File Synchronizer.+",,"TFSyncMain");
win.setForeground(FMHwnd);
win.show(FMHwnd)
var QMHwnd = winex.waitVisible("Super Flexible File Synchronizer.+",,"TFSyncMain");
key.press( "F7" );
var vv=winex.waitEnabled("Super Flexible File Synchronizer.+","Scheduler Activity ","TFSyncMain","TElGroupBox");
win.setForeground(QMHwnd);
var FSchedulerBtnHwnd;
if(QMHwnd ==vv){
FSchedulerBtnHwnd =winex.findEx(QMHwnd,,"TElPopupButton",".+Scheduler");
sleep(3000);
//win.msgbox("FSchedulerBtnHwnd="+tostring(FSchedulerBtnHwnd));
//win.msgbox(win.getText(FSchedulerBtnHwnd));
//win.msgbox(win.getText(FSchedulerBtnHwnd)=="Stop Scheduler");
if(win.getText(FSchedulerBtnHwnd)=="Stop Scheduler"){
winex.mouse.click(FSchedulerBtnHwnd,68,8)
sleep(3000);
}
}
process.kill("SuperFlexibleSynchronizer.exe");
sleep(6000);
}
else{
if(process.find("ExtremeSyncService.exe")){
process.execute( "I:\SuperFlexible\SuperFlexibleSynchronizer.exe");
var PMHwnd = winex.waitVisible("Super Flexible File Synchronizer.+",,"TFSyncMain");
win.setForeground(PMHwnd);
key.press( "F7" );
var Pvv=winex.waitEnabled("Super Flexible File Synchronizer.+","Scheduler Activity ","TFSyncMain","TElGroupBox");
win.setForeground(PMHwnd);
if(PMHwnd ==Pvv){
var PSchedulerBtnHwnd =winex.findEx(PMHwnd,,"TElPopupButton",".+Scheduler");
sleep(3000);
//win.msgbox("PSchedulerBtnHwnd="+tostring(PSchedulerBtnHwnd));
if(win.getText(PSchedulerBtnHwnd)=="Stop Scheduler"){
winex.mouse.click(PSchedulerBtnHwnd,68,8)
}
sleep(3000);
}
process.kill("SuperFlexibleSynchronizer.exe");
sleep(6000);
}
}
process.execute( "I:\SuperFlexible\SuperFlexibleSynchronizer.exe")
//winex.wait( 父窗口标题,控件文本 )
var MHwnd = winex.waitVisible("Super Flexible File Synchronizer.+",,"TFSyncMain");
win.setForeground(MHwnd);
key.press( "F7" );
var vv=winex.waitEnabled("Super Flexible File Synchronizer.+","Scheduler Activity ","TFSyncMain","TElGroupBox");
//win.msgbox("vv="+tostring(vv));
win.setForeground(MHwnd);
//win.msgbox("MHwnd="+tostring(MHwnd));
if(MHwnd ==vv){
var SchedulerBtnHwnd =winex.findEx(MHwnd,,"TElPopupButton",".+Scheduler");
sleep(3000);
//win.msgbox("SchedulerBtnHwnd="+tostring(SchedulerBtnHwnd));
if(win.getText(SchedulerBtnHwnd)=="Start Scheduler"){
winex.mouse.click(SchedulerBtnHwnd,68,8);
}
}
flag=false;
}
}
mainForm.enableDpiScaling();
mainForm.show();
return win.loopMessage();
第一次用这个写程序 有些乱 |
|