PPCGeeks Forums HTC Arrive HTC HD2 HTC Thunderbolt HTC Touch Pro 2 HTC Evo 4G HTC Evo 3D Samsung Galaxy S II Motorola Droid X Apple iPhone Blackberry
Go Back   PPCGeeks > Windows Mobile > WM HTC Devices > HTC Touch Pro 2
Register Community Search

Notices


Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 04-11-2011, 07:47 AM
quick99si's Avatar
Halfway to VIP Status
Offline
Pocket PC: Nexus S - E3GT - Epic 3G
Carrier: SERO $30
Location: Chicago, IL
 
Join Date: Dec 2007
Posts: 631
Reputation: 1245
quick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on rep
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

Here's what I put together, it's semi-tested:
Code:
varAutoRunTime="00:01"
 
varSelf = SystemPath("ScriptPath") \ SystemPath("ScriptName") & SystemPath("ScriptExt")
varMort = SystemPath("ScriptExe") \ "MortScript.exe"
 
varAutoRunTimeH = part(varAutoRunTime,":",1)
varAutoRunTimeM = part(varAutoRunTime,":",2)
 
If(varAutoRunTimeH < 0 OR varAutoRunTimeH > 23 OR varAutoRunTimeM < 0 OR varAutoRunTimeM > 60)
   varAutoRunTimeH="07"
   varAutoRunTimeH="00"
EndIf
 
varTomorrow = TimeStamp()+86400
varTomorrowMidnight = varTomorrow - (FormatTime("H",varTomorrow)*3600) - (FormatTime("i",varTomorrow)*60) - (FormatTime("s",varTomorrow))
varTomorrowSchedule = varTomorrowMidnight + (varAutoRunTimeH*3600) + (varAutoRunTimeM*60)
You can combine the last 3 lines into one i you'd like. I just posted it that way to make it more legible online.

And then for the notification queue:
Code:
RemoveNotifications(varMort,"""" & varSelf & """")
RunAt(varTomorrowSchedule,varMort,"""" & varSelf & """")

Last edited by quick99si; 04-11-2011 at 09:23 AM.
Reply With Quote
  #12 (permalink)  
Old 04-11-2011, 10:22 AM
elesbb's Avatar
Super genious in training
Offline
Pocket PC: HTC Touch Pro 2
Carrier: Sprint
Threadstarter
Location: PA
 
Join Date: Jun 2010
Posts: 1,198
Reputation: 1600
elesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on rep
Mentioned: 42 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

Quote:
Originally Posted by NinjaDuck View Post
GAlarm - is a great alarm clock and also lets you schedule programs to run instead of alarms. Well worth the $$.

I use this , however , i also have pocketshield . and i have the reg entry SLEEPTIME set to 5 so when i get a text while my phones in my pocket it will screen off in 5 seconds . unfourtunatly , when i have my alarm go off , 5 seconds isnt enough for pocketshield to unlock itself once galarm powers up (have galarm in the exceptions list) so at midnight , i want to run a script that will reset the SLEEPTIME reg entry to 30 . Thanks though !
Reply With Quote
  #13 (permalink)  
Old 04-11-2011, 10:50 AM
elesbb's Avatar
Super genious in training
Offline
Pocket PC: HTC Touch Pro 2
Carrier: Sprint
Threadstarter
Location: PA
 
Join Date: Jun 2010
Posts: 1,198
Reputation: 1600
elesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on rep
Mentioned: 42 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

Quote:
Originally Posted by quick99si View Post
Forget taking it elsewhere, we can solve it here

I know you said you just wanted help and not a solution, but first, I'm assuming you've referred to the *complete* manual? You can download it in HTML for viewing on your phone, use this clickable PDF: http://www.sto-helit.de/downloads/mo...ipt-Manual.pdf, etc..

For your scheduling needs, you can would make the notification from within the script that is being scheduled. Before doing this, I advise removing the script from the Windows notifications queue first using the following command:

Code:
RemoveNotifications(applications, parameter)
For application, you'll reference MortScript.exe (full path), and for the parameter, you will need the full path and filename of your script in quotes. SystemPath() is used for both. That command ensures that you won't leave duplicates in the queue.

As far as scheduling the execution, it's not as straightforward and frankly, I'm still thinking of the most elegant way myself. My elementary instict was to do something like:

Code:
GetTime(varTmp,varTmp,varTmp,varDay,varMonth,varYear)
varSelf=SystemPath("ScriptPath") + SystemPath("ScriptName") + SystemPath("ScriptExt") +
RunAt(varYear,varMonth,varDay+1,"0","01",varSelf)
But the problem arises with the day+1 computation... it won't work all that well on April 30th trying to schedule itself for 04-31-2011 00:01, then 4-32, 4-33, etc... You would need to use some if statements but it gets ugly with the different number of days or different months, and so on.

The way around this is to use Unix timestamp and time formatting.

Code:
9.11.2  Formatted output (FormatTime)
string = FormatTime( format [, timestamp ] )
Returns the time of the timestamp, or the current time if none is given, formatted corresponding to 
the format string.
These characters will be replaced with the corresponding value:
H Hour (00-23)
h Hour (01-12)
a am/pm
A AM/PM
i Minute (00-59)
s Seconds (00-59)
d Day (01-31)
m Month (01-12)
Y Year (4 digits)
y Year (2 digits)
w Day of week (0=Sunday to 6=Saturday)
u Unix timestamp
{MM}Month name (e.g. “January”)
{M} Month name abbreviated (e.g. “Jan”)
{WW}Day of week name (e.g. “Monday”)
{W} Day of week name abbreviated (e.g. “Mon”)
All other characters remain unchanged.
Note all return values will be strings. This is to allow leading zeroes, like "02" for february, which 
is handy to combine filenames. However, it might cause troubles when using arrays. You either 
need to assign the array elements with strings (“Month["01"] = "First"”) or convert the string to a 
number, e.g. by using “FormatTime("m")*1”.
Examples:
x = FormatTime( "h:i:s a" )
x = FormatTime( "m/d/Y", TimeStamp() + 86400 )
The last line adds exactly 24hours to the current time and returns it in "04/12/2011" format. That's a bit useless to you since you'd have to parse it further. Instead, I would advise passing "u" as the format and then using that value with RunAt() for scheduling the next execution.
Code:
9.6.5  Execute application at a given time (RunAt):
RunAt( Unix timestamp, application [, parameter] )
Again, application is the Mortscript EXE and parameter is your script in quotes. The only concern I have is that if you keep rescheduling the script for 24hrs in the future, you may start seeing time added due to delays in the event that your phone is off at that time and the script is execute 6hrs late or something. Therefore, the unix timesamp() + 24hrs thing is only effective for extracting the date of the next day (not the time).

So the final hurdle involves getting tomorrow's time in Unix format, converting that time to a regular time format, changing that new time to 00:01 while leaving the d/m/y intact, change it back to Unix, and then pass that value to RunAt().

There are a couple of different ways of doing it, I'll post mine when I sit down and get my script finalized. I'd like to see what you come up with as well.

Alright , thank you so much for this .. im still fuzzy , however i started wondering into the mist . Where before i was too confused to even start . the mist was a dense fog where i couldnt even see my footing .

I noticed you put up your own script , ill try my version today . may not get it done , have a research paper to wright , but ill try my best ! Thanks again so very much !!!!
Reply With Quote
  #14 (permalink)  
Old 04-11-2011, 11:39 AM
quick99si's Avatar
Halfway to VIP Status
Offline
Pocket PC: Nexus S - E3GT - Epic 3G
Carrier: SERO $30
Location: Chicago, IL
 
Join Date: Dec 2007
Posts: 631
Reputation: 1245
quick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on rep
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

I tested it in my FTP Backup script and it works/schedules perfectly fine so far
Reply With Quote
  #15 (permalink)  
Old 04-11-2011, 12:42 PM
elesbb's Avatar
Super genious in training
Offline
Pocket PC: HTC Touch Pro 2
Carrier: Sprint
Threadstarter
Location: PA
 
Join Date: Jun 2010
Posts: 1,198
Reputation: 1600
elesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on rep
Mentioned: 42 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

Quote:
Originally Posted by quick99si
Code:
varAutoRunTime="00:01"

varSelf = SystemPath("ScriptPath") \ SystemPath("ScriptName") & SystemPath("ScriptExt")
varMort = SystemPath("ScriptExe") \ "MortScript.exe"

varAutoRunTimeH = part(varAutoRunTime,":",1)
varAutoRunTimeM = part(varAutoRunTime,":",2)

If(varAutoRunTimeH < 0 OR varAutoRunTimeH > 23 OR varAutoRunTimeM < 0 OR varAutoRunTimeM > 60)
varAutoRunTimeH="07"
varAutoRunTimeH="00"
EndIf

varTomorrow = TimeStamp()+86400
varTomorrowMidnight = varTomorrow - (FormatTime("H",varTomorrow)*3600) - (FormatTime("i",varTomorrow)*60) - (FormatTime("s",varTomorrow))
varTomorrowSchedule = varTomorrowMidnight + (varAutoRunTimeH*3600) + (varAutoRunTimeM*60)
can you possibly put comments as to what each line is doing ? i think i understand the whole timestamp and unix format .. i beilieve with the IF statement you are ensuring it to be at MIDNIGHT , considering TimeStamp get the amount of seconds FROM 01/01/1970 ...
Reply With Quote
  #16 (permalink)  
Old 04-11-2011, 10:43 PM
mwalt2's Avatar
VIP Member
Offline
Pocket PC: Evo 3D
Carrier: Sprint
 
Join Date: Apr 2007
Posts: 1,759
Reputation: 5415
mwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the communitymwalt2 is a trusted member of the community
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

This is off topic as far as mortscript is concerned, but I've also been having problems with g-alarm since I bought pocketshield. elesbb, are you able to use the g-sensor in g-alarm (like shake to snooze) with pocketshield installed? Even though I don't use any g-sensor settings in pocketshield, it still snoozes g-alarm almost instantly after the alarm goes off. Removing pocketshield makes it so this isn't a problem anymore, so it must be doing something. I've also had problems with it turning off g-alarm too soon as you have had (with the g-sensor setting in g-alarm disabled).
Reply With Quote
  #17 (permalink)  
Old 04-11-2011, 11:10 PM
elesbb's Avatar
Super genious in training
Offline
Pocket PC: HTC Touch Pro 2
Carrier: Sprint
Threadstarter
Location: PA
 
Join Date: Jun 2010
Posts: 1,198
Reputation: 1600
elesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on rep
Mentioned: 42 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

Quote:
Originally Posted by quick99si View Post
I tested it in my FTP Backup script and it works/schedules perfectly fine so far
thank you !

one quick question , when the command runAt is executed , does the script that executes that command need to be ran again ? or does the device know when to run the desired program automatically after you execute the script ?

like in the code you listed , it uses the variable (varTomorrowSchedule) to tell the runAt command when to launch specified program , mus the script be constantly ran to reassign the value of varTomorrowSchedule ? or once you run the script once that's it ? thanks again man . You rock !
Reply With Quote
  #18 (permalink)  
Old 04-11-2011, 11:24 PM
elesbb's Avatar
Super genious in training
Offline
Pocket PC: HTC Touch Pro 2
Carrier: Sprint
Threadstarter
Location: PA
 
Join Date: Jun 2010
Posts: 1,198
Reputation: 1600
elesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on repelesbb is halfway to VIP status based on rep
Mentioned: 42 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

Quote:
Originally Posted by mwalt2 View Post
This is off topic as far as mortscript is concerned, but I've also been having problems with g-alarm since I bought pocketshield. elesbb, are you able to use the g-sensor in g-alarm (like shake to snooze) with pocketshield installed? Even though I don't use any g-sensor settings in pocketshield, it still snoozes g-alarm almost instantly after the alarm goes off. Removing pocketshield makes it so this isn't a problem anymore, so it must be doing something. I've also had problems with it turning off g-alarm too soon as you have had (with the g-sensor setting in g-alarm disabled).
1st , make sure you have galarm added to the aplication exceptions list found under the unlocking tab (see attatched) in order for pocketshield to allow the alarm to sound .

the problem I have experienced ,
I personally found the reg entry which handles the time the screen stays on once it wakes up , while its still locked . I changed it to 5 , allowing me to save battery when I get a text message and my phones in my pocket . Since it doesn't screen off from the proximity sensor . However , when my device wakes for an alarm , the galarm application doesn't fully load in 5 seconds to the point where pocketshield notices it as an active application and shuts the screen off keeping the alarm from sounding until the screen turns on again . But when I have the sleep time set to 30 seconds , it unlocks due to the exception added for galarm , and my alarm sounds like its supposed to .

so I have 2 mortscripts written which allows me to change the sleep time without using resco or any other reg editor . And what I wanted to do was have each script run at a certain time , like for me , have the 30 second script run at midnight , so my alarm goes off at 6 when I wake up , then having the 5 second script run to restore the 5 second sleep at say 630 when I have already woken .

if your device is unlocked , the g sensor should function correctly with galarm , I haven't experienced any issues when it unlocks to sound the alarm . Let me know if you get it working or what other problems you run into .
Attached Images
File Type: jpg ScreenShot3.jpg (7.7 KB, 5 views) Click for barcode!

Last edited by elesbb; 04-11-2011 at 11:27 PM.
Reply With Quote
  #19 (permalink)  
Old 04-12-2011, 06:35 AM
quick99si's Avatar
Halfway to VIP Status
Offline
Pocket PC: Nexus S - E3GT - Epic 3G
Carrier: SERO $30
Location: Chicago, IL
 
Join Date: Dec 2007
Posts: 631
Reputation: 1245
quick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on rep
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

Quote:
Originally Posted by elesbb View Post
can you possibly put comments as to what each line is doing ? i think i understand the whole timestamp and unix format .. i beilieve with the IF statement you are ensuring it to be at MIDNIGHT , considering TimeStamp get the amount of seconds FROM 01/01/1970 ...

Tell me if this helps (I apologize in advance for the lengthy notes!).

Quote:
varAutoRunTime="00:01" <--- this is a variable that stores a time for daily execution. Doing this lets you easily adapt it to other scripts. You can change this to anything you want really, like 06:00 for 6AM or 18:30 for 6PM. I don't recommend 00:00 because the phone updates the calendar at that time every day. Most of my scripts are at 3AM, 6AM, etc..

varSelf = SystemPath("ScriptPath") \ SystemPath("ScriptName") & SystemPath("ScriptExt")
varMort = SystemPath("ScriptExe") \ "MortScript.exe" <--- these two variables just point to the Mortscript shell exe and your own script. It's used later to schedule a notification.

varAutoRunTimeH = part(varAutoRunTime,":",1)
varAutoRunTimeM = part(varAutoRunTime,":",2) <--- extract 2 integers from the time setting above using the colon as the separator. the H variable will have something like "00" and M will have "01" (1 minute past midnight).

If(varAutoRunTimeH < 0 OR varAutoRunTimeH > 23 OR varAutoRunTimeM < 0 OR varAutoRunTimeM > 60)
varAutoRunTimeH="07"
varAutoRunTimeH="00" <---making sure that we didn't set the time incorrectly in the first line above. H has to be between 0 and 23 inclusive, while M has to be between 0 and 59 inclusive. I guess I should have a 59 instead of a 60 in this line actually, but they'll work identically for our purposes. If you set the first line above to something like 24:70, it'll default to 7AM (07:00) because it assumes you've made a mistake. These two lines are totally optional obviously.
EndIf

varTomorrow = TimeStamp()+86400 <--- this points to a time exactly 24hrs from now. TimeStamp() returns the current time and 86400 is added, which translates to 24hrs in seconds. The time is in Unix format (seconds since 1/1/70). We need to use the Unix format so we can avoid dealing with figuring out tomorrow's date (no need to roll over months, years, Feb issues, etc..).

varTomorrowMidnight = varTomorrow - (FormatTime("H",varTomorrow)*3600) - (FormatTime("i",varTomorrow)*60) - (FormatTime("s",varTomorrow)) <--- this line computes the Unix time of tomorrow's date at midnight. It's basically tomorrow's time (24hr in the future), minus the hours/minutes/seconds past midnight so it's adjusted to 0:00:00 of tomorrow's date. If the current time is 04-12-2011 6AM, varTomorrowMidnight will add 24hrs to the current time and then subtract 6hrs (21600 seconds). The result is 04-12-2011 0:00 in Unix format.

varTomorrowSchedule = varTomorrowMidnight + (varAutoRunTimeH*3600) + (varAutoRunTimeM*60)<--- this line basically uses tomorrow's midnight time and adds whatever we set in the first line above. For you, if you're using 00:01 up there, it'll only add 1 minute (60 seconds) to varTomorrowMidnight. You can see that you can combine this line with the previous if you'd like to optimize the script - no need to go back to midnight, and then forward to a scheduled time.
Reply With Quote
This post has been thanked 1 times.
  #20 (permalink)  
Old 04-12-2011, 06:42 AM
quick99si's Avatar
Halfway to VIP Status
Offline
Pocket PC: Nexus S - E3GT - Epic 3G
Carrier: SERO $30
Location: Chicago, IL
 
Join Date: Dec 2007
Posts: 631
Reputation: 1245
quick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on repquick99si is halfway to VIP status based on rep
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Certain script run at a certain time

Quote:
Originally Posted by elesbb View Post
thank you !

one quick question , when the command runAt is executed , does the script that executes that command need to be ran again ? or does the device know when to run the desired program automatically after you execute the script ?

like in the code you listed , it uses the variable (varTomorrowSchedule) to tell the runAt command when to launch specified program , mus the script be constantly ran to reassign the value of varTomorrowSchedule ? or once you run the script once that's it ? thanks again man . You rock !
Yes, it does. The RunAt() command can only schedule one notification at a time, so the commands above must be left in the script in order to have it schedule its notification on its own.

The first time you run it will be manual and it will add itself to the notification queue for tomorrow at midnight. When it runs at that time, it'll add itself to the queue on the following day at midnight, and so on.

You can actually see all the notifications on your device using dotFred's Task Manager (to verify that your script is working or the delete/add notifications manually). He's the author of PIMBackup and they're both fantastic programs IMO. Check out his site at: Dotfred's TaskMgr
Reply With Quote
This post has been thanked 1 times.
Reply

  PPCGeeks > Windows Mobile > WM HTC Devices > HTC Touch Pro 2


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 11:25 AM.


Powered by vBulletin® ©2000 - 2025, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0
©2012 - PPCGeeks.com