FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

Cant figure out the TimeSelectorDialog widget

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Windows
View previous topic :: View next topic  
Author Message
explicitlyrics
Newbie


Joined: 23 Jan 2006
Posts: 8
Location: www.rentapent.com

PostPosted: Wed Aug 29, 2007 5:33 am    Post subject: Cant figure out the TimeSelectorDialog widget Reply with quote

I have a list widget that runs fine, but cannot get my TimeSelector widget working. If I select a certain option from the list, I want to input a time value (which is the time before my computer goes to sleep). I would then convert that DATE object into seconds and use it in a Shell script.

I have tried all sorts of things and it is driving me mad. This is where I have reached:


[quote]
else if( option == "Timed Sleep" )
{
{
var SleepMenu = CreateTimeSelectorDialog( "SleepMenu_");
SleepMenu.title = "Enter Sleep duration";
SleepMenu.value = 0;
theTerminal.Push( SleepMenu );
}
function SleepMenu_ValueUpdated(theAnswer)
{
ShowMessage("Timed Sleep has been set.2");
var duration = theAnswer.value.getHours() * 3600;
duration += theAnswer.value.getMinutes() * 60;
ShowMessage("Timed Sleep has been set.");
var appstart = new ActiveXObject('WScript.Shell');
if (appstart)
appstart.Run("poweroff standby -scheduled -seconds [b]duration[/b]");
}
}
[/quote]

Where the code starts at the list element option and then goes to the code I want to run. The highlighted duration is supposed to be the time in seconds before standby.

Thanks very much in advance.
Back to top
View user's profile Send private message Visit poster's website
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Aug 29, 2007 1:13 pm    Post subject: Reply with quote

Hi,

There are two problems with your code. One obvious, and one not so obvious:

1. You need to compose your command line more carefully. This:
[code:1]appstart.Run("poweroff standby -scheduled -seconds duration");[/code:1]
should be:
[code:1]appstart.Run("poweroff standby -scheduled -seconds " + duration );[/code:1]

2. The not so obvious problem is that the value member of "theAnswer" is a VT_DATE value, so you cannot treat it like a JScript Date object. Here's what you'd do in your handler function:
[code:1]var dateObject = new Date(theAnswer.value); // create a JScript date object from a VT_DATE value
var duration = dateObject.getHours() * 3600;
duration += dateObject.getMinutes() * 60;
// and so on...[/code:1]

I hope this helps.

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
explicitlyrics
Newbie


Joined: 23 Jan 2006
Posts: 8
Location: www.rentapent.com

PostPosted: Wed Aug 29, 2007 2:13 pm    Post subject: Reply with quote

Thanks for that, I had just noticed my fallacy with the command line, but would not have realised it was a VT_DATE object (how that is different Im still not sure).

My problem is that my SleepMenu_ValueUpdated function does not seem to be running once the user has entered a value on the phone. Is there something that has to be done to make the ValueUpdated function run when the user presses ok?

Thanks very much :)
Back to top
View user's profile Send private message Visit poster's website
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Aug 29, 2007 3:45 pm    Post subject: Reply with quote

You're going to want to use this function prototype instead:

function SleepMenu_Ok(theWidget)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
explicitlyrics
Newbie


Joined: 23 Jan 2006
Posts: 8
Location: www.rentapent.com

PostPosted: Wed Aug 29, 2007 3:49 pm    Post subject: Reply with quote

Awesome, thank you so much for your help!

I was wondering if that was the right prototype, but couldnt see any database of which ones go with which widgets in the API files.

EDIT: Still not running any of the code under the SleepMenu_Ok prototype. Cant think of anything else now.
Back to top
View user's profile Send private message Visit poster's website
explicitlyrics
Newbie


Joined: 23 Jan 2006
Posts: 8
Location: www.rentapent.com

PostPosted: Wed Aug 29, 2007 4:15 pm    Post subject: Reply with quote

Sorry for the hassle, Ive realised it is an _OK prototype not _Ok and it now works.

Keep up the work on such a great piece of software.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Windows All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group