XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently March 28th, 2024, 5:47 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Help with Timed Shutdown
PostPosted: June 21st, 2012, 2:58 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
Hi, I am trying to create a widget that will allow the user to set a time that the computer will shutdown every night.
This code works, shutting down at the set time and asking the user to abort the shutdown if required.
But if the user does not respond to the "Confirm" abort shutdown request it will remain active, while the system is shutting down.
Is there a way to dismiss the confirm request with a setTimeout? or another method all together ?
Thank you for your help :)

function TimedShutdown()
{
var NowDate = new Date();
var NowHour = NowDate.getHours();
var NowMin = NowDate.getMinutes();
var OffHour = NowHour; //OffHour will be set by user
var OffMin = NowMin; //OffMin will be set by user

if(NowHour == OffHour && NowMin == OffMin) //shutdown if time match
run("shutdown.exe -s -t 60");

//setTimeout("doSomething()",10000); //can it be used to dismiss the confirm ?

var answer = Confirm("Abort Shutdown ?") // ask user to abort shutdown
if (answer)
run("shutdown.exe -a");
}


Top
 Profile  
 
PostPosted: June 21st, 2012, 9:55 pm 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313
hi,meme,nice to meet you
some main code:
function timercore1OnUpdate(Sender)
{
var NowDate = new Date();
var NowHour = NowDate.getHours();
var NowMin = NowDate.getMinutes();
var OffHour = parseInt(edit1.text);
var OffMin = parseInt(edit2.text);
if(NowHour == OffHour && NowMin == OffMin)
{
timercore1.Enabled=false;
if(confirm("shutdown"))run("shutdown.exe -s -t 60");
else setTimeout('dosomething',10000);
}
}

function dosomething()
{
if(confirm("shutdown")) run("shutdown.exe -s -t 60");
else setTimeout('dosomething',10000);
}


Attachments:
shutdown.rar [8.14 KiB]
Downloaded 303 times
Top
 Profile  
 
PostPosted: June 22nd, 2012, 2:38 am 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
Thanks again qiancang for your assistance, very helpful.

Greatly appreciated :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 69 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group