PDA

View Full Version : MortScript examples accumulation


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [17] 18

RoryB
18th May 2011, 03:58 PM
I have looked in the JMLSenseMenu examples and it appears it can run executable files and change registry settings, but I do not see where it can change xml or txt or ini files. Hopefully I am wrong.

RoryB
18th May 2011, 04:13 PM
what about reading the skin.xml
searching for, eg:

<Image x="xxx" y="xxx" source="xxxxx.png">
<OnClick File="\Windows\xxxxx.exe" />
</Image>

then deleting the line of text in the skin.xml
the replace with:

<Image x="xxx" y="xxx" source="xxxxx.png">
<OnClick File="\Windows\xxxxx.exe" />
</Image>

redrawtoday

?

i dont mind if i need xxx number of these scripts in my wiindows folder because the UI is definatly worth having for my rom (also all the scripts will be tiny in .mb so i doubt anyone will care :))

RnI feel I could get the grouping set up based on the < as the start of a group and /> as the group's end to be able to nest other < items in the group. I also can use <! as a comment flag so those lines would not be a choice.

I think my bigger problem is parsing through the multiple x=y parts and being sure I get them correctly. Could they ever be x x x=yy yy or similar? Spaces can mess things up especially since the first thing I notice as a separator appears to be blank space. I can handle blank spaces in between " marks and even the ' marks.

Replace(string, old_characters, new_characters) would work after you do a string = readfile(xml_file) then make changes and do a writefile(xml_file)

raving_nanza
18th May 2011, 04:15 PM
i want to use mortscript to edit the skin.xml
(if your thinking i meant editing the skin.xml with jmlsense)

*jmlsense does run .mscr files :)

RoryB
18th May 2011, 04:55 PM
i do not think it will read the xml file to give you your choices of what to edit. You would have to create a xmu file to run in JMLMenu and still have the MortScript to show you the choices. It would be an extra wrapper.

raving_nanza
18th May 2011, 05:43 PM
the idea has changed dude:

i do not need mortscript to show choices anymore ;) eg


i have now created a UI with jmltoday, this will show all the avaliable options that you can change and then run a small mortscript to apply the settings.

eg,

i have created this with jmlsense

program 1/program list = choose program/apply settings? = ok or cancel

*all i need now is for you to make 1 single mortscript example to apply 1 of these programs to "program 1".

ill then edit that mortscript for each of the settings to apply. (ill have 12xprogram options in the first screen) (ill also have lots of mortscripts in my windows folder but i dont care :))

my UI does all the hard work so mortscript/YOU do not have to, makes life easier :)



what i need is a mortscript to just edit the skin.xml

eg, for program 1 (x="0" y="275")

xmlread("program files\rltoday\default\skin.xml")
if("<Image x="xxx" y="xxx" source="xxxxx.png">
<OnClick File="\Windows\xxxxx.exe" />
</Image>")
delete text
replace with("<Image x="XXX" y="XXX" source="OPERA.png">
<OnClick File="\Windows\OPERA.exe" />
</Image>")
endif
redrawtoday


so i can have one of these scripts for each "apply settings"


Rn

RoryB
18th May 2011, 06:42 PM
First stab. Looks like your xml file is encoded in ANSI format.
If(FileExists("\program files\rltoday\default\skin.xml"))
xmlread = readfile("\program files\rltoday\default\skin.xml")
xmlread = Replace(xmlread, "<Image x=""xxx"" y=""xxx"" source=""xxxxx.png""><OnClick File=""\Windows\xxxxx.exe"" />", "<Image x=""XXX"" y=""XXX"" source=""XXXXX.png""><OnClick File=""\Windows\xxxxx.exe"" />")
WriteFile("\program files\rltoday\default\skin.xml", xmlread )
Sleep(3000)
CloseFile("\program files\rltoday\default\skin.xml" )
redrawtoday
EndIfRemember Replace does so for all occurances in the xmlread variable, so if you have two of the old string it will replace both with the new string.
ORIf(FileExists("\program files\rltoday\default\skin.xml"))
xmlread = readfile("\program files\rltoday\default\skin.xml")
xmlread = Replace(xmlread, "<Image x=""xxx"" y=""xxx"" source=""xxxxx.png""><OnClick File=""\Windows\xxxxx.exe"" />", "<Image x=""XXX"" y=""XXX"" source=""XXXXX.png""><OnClick File=""\Windows\xxxxx.exe"" />")
WriteFile("\program files\rltoday\default\skin.xml", xmlread )
Sleep(3000)
redrawtoday
EndIf

raving_nanza
18th May 2011, 07:02 PM
line 4 has an error either a comma is missing or closing parathesesis is missing..

try make a script with this instead because the skin still works with just one line of code, eg


" <Image x="xxx" y="xxx" source="xxx.png"><OnClick File="\Windows\xxx" /></Image>"


btw, ill also try and work on this too, just needed an example to work with ;)

it might be best to rename it to .txt to use readfil

RoryB
18th May 2011, 08:33 PM
line 4 has an error either a comma is missing or closing parathesesis is missing..

try make a script with this instead because the skin still works with just one line of code, eg


" <Image x="xxx" y="xxx" source="xxx.png"><OnClick File="\Windows\xxx" /></Image>"


btw, ill also try and work on this too, just needed an example to work with ;)

it might be best to rename it to .txt to use readfilUpdated code in previous post. Needed some "" instead of "
Also, changed to single line so you can have it together.

raving_nanza
18th May 2011, 09:04 PM
Error on this CloseFile

when checking the xml after running the script there is no change.

i think it would be best to convert it to .txt

Rename("\program files\rltoday\default\skin.xml" , "\program files\rltoday\default\skin.txt")


Rn

ill continue to work on the UI :)

RoryB
18th May 2011, 09:17 PM
Error on this CloseFile

when checking the xml after running the script there is no change.

i think it would be best to convert it to .txt

Rename("\program files\rltoday\default\skin.xml" , "\program files\rltoday\default\skin.txt")


Rn

ill continue to work on the UI :)Probably needs a sleep period before trying to close. You could try without the close.
I am not having trouble editing it as an xml file.

See previous post

raving_nanza
18th May 2011, 09:43 PM
it says "closefile" is an unknown command

i tried deleting the "close file" command and now no error.

but when i check the skin.xml there is no change

fyi - i do have this in my skin.xml for it to change, otherwise nothing would change :)

<Image x=""xxx"" y=""xxx"" source=""xxxxx.png""><OnClick File=""\Windows\xxxxx.exe"" />


i appreciate you help dude, keep up the good work :D

RoryB
18th May 2011, 09:54 PM
it says "closefile" is an unknown command

i tried deleting the "close file" command and now no error.

but when i check the skin.xml there is no change

fyi - i do have this in my skin.xml for it to change, otherwise nothing would change :)

<Image x=""xxx"" y=""xxx"" source=""xxxxx.png""><OnClick File=""\Windows\xxxxx.exe"" />


i appreciate you help dude, keep up the good work :DWhat version of MortScript are you running?
If you are not sure you can run a script of this

Message(MortScriptVersion())

The format in your xml should not have the "", but only the regular "

<Image x="xxx" y="xxx" source="xxxxx.png"><OnClick File="\Windows\xxxxx.exe" />

The "" tells Mortscript that it is looking for a " in the text string since it uses a single " to call out a text string.

raving_nanza
18th May 2011, 10:34 PM
mortscript version 4.2.0.0 - is it the latest version?

right, ive modified my skin.xml with what you said
i ran the new mortscript you gave me and i still have the closefile error but... the skin.xml now get edited! :D

you da man! ;)

ill get to work on all the UI, also including all my ifs and endifs on each script for the customisation of my roms today screen, i now think it is definatly possable!


**ill swith my xda skin (coz i use the classic skin) and i will spam all the "thanks" buttons on all your posts - only from when you started helping me though, there is quite a few posts though :D:D:D


Rn

RoryB
18th May 2011, 11:45 PM
I have 4.3 beta 15

See the wiki link in my sig

raving_nanza
19th May 2011, 12:07 AM
roger that ;)

*downloaded, ill turn it into an EXT and add it to my rom asap

FYI - i can only click the thanks button 5 times per day (stupid xda :mad:)
ill spam it every day untill i get to the first post i made :D:rolleyes: LOL

ive hit a little bug in my UI but ill edit it so it looks like this:

1)Change Programs/Programs List/Program Option List eg, all XY options (12 options)/ok-cancel/mortscripts
2)Restore Default/ok-cancel/mortscript
3)Refresh Today/ok
4)Cancel/ok

ill get this done tonight and if i have enough time ill rewrite the example you gave me for all the programs :)
eg, the mortscript will have an IF to overwrite every single option avaliable so no matter what is currently in use for a specific XY it will overwrite it and work :)

i am VERY impressed with the progress we have made :D
(me for UI and you for the mortscripts)


Rn

sudist
21st May 2011, 06:26 AM
When I saw a "Pim Backup script" a few pages back, I thought... why not share my.
First of all, mortscript is helping me to do some daily boring stuff and must not be to heavy on batterylife.


ToggleDisplay (FALSE)
#Here I play a sound to say which script is starting
#sounds you make overhere : http://www2.research.att.com/~ttsweb/tts/demo.php
PlaySound ("\lsac.wav")
run ("\windows\pimbackup.exe")
#cnt=2 is waiting for pimbackup.exe to start
cnt=2
while (cnt=2)
k= ColorAt (24,40)
if (k =16711680)
sleep 100
mouseclick (190,270)
Sleep 600
mouseclick (190,270)
Sleep 30000
#cnt=1 is waiting for pimbackup.exe to end by controling a pixel, in the second row
cnt=1
While (cnt=1)
c = ColorAt (229,283)
If (c = 10264220)
SendSpecial ("LeftSoft")
PlaySound ("\lsef.wav")
sleep 1000
exit
else
Sleep (3000)
endif
EndWhile
else
Sleep (500)
endif
EndWhile

vivekiny2k
28th May 2011, 02:14 PM
Hi all,
a few questions.

1. Is there a way to capture error and continue processing? the script seems to terminate if the window is found inactive.
2. is there a way to capture an event to break a loop (e.g. in the continuous camera script, break the loop if a particular key is pressed).
3. this is really not a mortscript Q, but it works in mortscript and not in lnk. anybody knows why? lnk opens the program but not in the folder I want. Ths problem with using mortscript is it shows as a mortscript icon in my quick links rather than explorer.

MSCR
run("\program files\resco explorer\explorer.exe", "\storage card\my voices")

lnk
76#"\program files\resco explorer\explorer.exe", "\storage card\my voices"

ai6908
3rd June 2011, 09:32 PM
3. this is really not a mortscript Q, but it works in mortscript and not in lnk. anybody knows why? lnk opens the program but not in the folder I want.

That is probably the issue with the program, program should be able to handle arguments. If it does not, then you wont be able to pass arguments.

To overcome the mortscript icon, you can modify the lnk to specify an icon from the dll of your choice.

aleck1
5th June 2011, 03:05 PM
Can someone help me doing a script that:

1) detects incoming call
2) if caller has a certain number, for example ="12345"
3) then it starts a program: Run ("opera.exe")

I am a beginner so i dont know how to do this
incoming call detection and number verification

lesscro
5th June 2011, 05:31 PM
i think you can detect incoming call using registry
HKLM/Sytem/phone/state not sure for directory

About number in same regitry directory (depend your os version) WM store num call

bismuth89
6th June 2011, 05:32 AM
Hi, is there a mortscript that would do something similar to the app lockdown in the link below?
http://forum.xda-developers.com/showthread.php?t=409135

It can ask for password when open any .lnk file, if the password is entered right then the desired program is launched.
What I need to do is locking Vito sms-chat, when someone click on the link to sms-chat.exe in start menu, they will be asked for password.

I tried searching this thread but couldn't find it.

RoryB
6th June 2011, 11:13 AM
Hi, is there a mortscript that would do something similar to the app lockdown in the link below?
http://forum.xda-developers.com/showthread.php?t=409135

It can ask for password when open any .lnk file, if the password is entered right then the desired program is launched.
What I need to do is locking Vito sms-chat, when someone click on the link to sms-chat.exe in start menu, they will be asked for password.

I tried searching this thread but couldn't find it.
Ask a question and if the answer does not equal the correct thing then give error message and exit. If the answer is correct start the program.

password = Input( "Please enter the password: ", "SECURITY", TRUE )
If ( password eq "1234" )
Run("\windows\program.exe")
Else
SleepMessage( 3, "You entered the wrong password")
End If

bismuth89
6th June 2011, 11:57 AM
Thanks a lot! work just like you said :D
Don't know that it's something so simple :o

ironhead65
8th June 2011, 08:18 PM
Are there any apps that can readback the stuff in the notification queue?

Say dump to a text or registry entry? I'm using Mort to add programs to the Notifications Queue. I would like to then display the apps on my today screen using the Billbord today item.

I did pop an e-mail to Dot Fred. I've not heard back. Maybe there are other "taskmanager" style programs that others can recommend? I could try getting a hold of one of the other authors.

Thanks!

--Ironhead

michoob
9th June 2011, 08:23 AM
@ironhead65: I've already looked for something like this some time ago, and unfortunately, Dot Fred's TskMgr is the only tool I've found so far which is good, but cannot return you a list of notifications that could be used within a MortScript :(.

ironhead65
9th June 2011, 12:48 PM
well, I was looking around at some programs that are out there.

It looks like Avianwave's Mute4 does this. I sent an e-mail to the author. It doesn't seem like it would be too difficult to do this, as he's already doing this for his mute4. So, the hard part would be stripping out most stuff, then making it open up in the background, read the .ini to determine WHICH .exe it's looking for (or command line input?), then read through the list and return every instance of mortscript.exe...to say the .ini. At this point, we can do whatever we want with the list.

My purpose being, I want to list some "runat" programs using the billboard plugin for the Today page. I know I can just list what I "think" is in the notification queue...but why not take it a step further (with some effort) and show actually what's in the queue??

--Ironhead

mitsi
10th June 2011, 07:43 AM
Hi all,

I have been having problems with getting sound when a new SMS arrives. I think it is quite well documented in these forums but I haven't been able to find a solution. Therefore, I decided to write a script for it. There have been some examples of these too in the forums but I wanted mine to be a simple as possible. Here is what I have:

Sleep(200)
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
if(SMS>0)
playsound("\Application Data\Sounds\OldPhone.wma")
Sleep(3000)
Else
Run("\Storage Card\Program Files\New SMS sound.mscr")
Endif

However, it doesn't seem to do anything. What have I done wrong? Any help would be very much appreciated :)

michoob
10th June 2011, 08:22 AM
Is New SMS sound.mscr the name of your script?
Then please note MortScript cannot run the same script twice at the same time.
So your script cannot run itself...
You should better try that:
While (1)
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
If (SMS>0)
playsound("\Application Data\Sounds\OldPhone.wma")
EndIf
Sleep(3000)
EndWhile
Personnally, I don't like this kind of loop script because it will increase your battery consumption...
It would be better by far that you manage to have Windows Mobile System SMS Notifications work on your device than using a MortScript to achieve that...

mitsi
10th June 2011, 08:38 AM
Thanks for your quick and clear reply. Perhaps I will try harder to get MS to work.

I have tried your script, but it doesn't seem to work. There are no error messages, but it just doesn't do anything. It baffles me. I have checked my registry and it does count the number of unread SMS's, so it can't be that.. :confused:

Maybe I can use a Mortscript that reads this script and then writes in the registry the value that MS uses for notifications.... Crazy solution though!

raving_nanza
10th June 2011, 08:39 AM
didnt work with .WMA (or use .WAV/.MP3)

suppose you could have two of the same scripts so you can bounce them from one another, eg

SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
if(SMS>0)
playsound("\XXXX\.MP3")
Else
Run("\XXXX\New SMS sound2.mscr")
Endif

SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
if(SMS>0)
playsound("\XXXX\.MP3")
Else
Run("\XXXX\New SMS sound1.mscr")
Endif

but like michoob said, it would probably be best if you use the windows notification because of battery drain.


Rn

michoob
10th June 2011, 10:06 AM
I have tried your script, but it doesn't seem to work. There are no error messages, but it just doesn't do anything. It baffles me. I have checked my registry and it does count the number of unread SMS's, so it can't be that.. :confused:
You might want to be sure that the script does what you want by adding a message for testing purpose:
While (1)
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
If (SMS>0)
Message("New SMS!")
EndIf
Sleep(3000)
EndWhile
If it works, then have a look at raving_nanza's proposal of using .WAV/.MP3 files.

Maybe I can use a Mortscript that reads this script and then writes in the registry the value that MS uses for notifications.... Crazy solution though!
Not only crazy, but totally not logical...
Because the registry the value that MS uses for notifications is certainly linked to "HKCU","\System\State\Messages\sms\Unread","Count".
The issue you have in not having native SMS notifications work, is not due to the trigger, but more to some bad configuration or ROM issue...

raving_nanza
10th June 2011, 11:16 AM
adding a message for testing purpose

just retested the script and comfirmed, .WMA does not work with playsound.. but .MP3/.WAV files defo work ;)

(fyi i do not think the sleep is needed, works fine without)


Rn

mitsi
10th June 2011, 01:40 PM
Raving_nanza and michoob, many thanks for your help. I have tested two separate mortscripts and the one which senses the unread sms works fine. The one I can't get to do anything is this:

playsound("\Application Data\Sounds\OldPhone.wav")

If I click on that mortscript alone, it does nothing. Shouldn't it play the .wav file? I have gone to the .wav file and clicked on it in file explorer and it works :confused:

This also doesn't work:
playsound("\Storage Card\Music\Duran Duran\04_Duran_Duran_-_Ordinary_World_(Single_Version)_(Greatest).mp3")

By the way, is there a code to vibrate too please?

michoob
10th June 2011, 02:24 PM
(fyi i do not think the sleep is needed, works fine without)
Removing the sleep will definitively drain your battery in an instant...
I would suggest to keep at least a sleep of 1000ms. I don't think you need to be more real-time than that for SMS notifications... :p

mitsi
10th June 2011, 02:38 PM
Thanks for your help again. I have changed my code so that it vibrates when I receive a new text.

While (1)
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
If (SMS>0)
Vibrate(100)
Sleep (100)
Vibrate(500)
Sleep (100)
Vibrate(100)
Sleep (3000)
Vibrate(500)
Sleep (100)
Vibrate(500)
Sleep (100)
Vibrate(500)
Vibrate(500)
Sleep (600000)
EndIf
Sleep(3000)
EndWhile


So it doesn't play a tune, but will vibrate a bit then sleep for 10 minutes until some more vibrations! If there are no SMS's, it will check every 3 seconds which is often enough for me and hopefully not too much of a battery drain.

I still don't understand why the playsound doesn't work. Perhaps it is something to do with my file associations and what opens what extentions. :confused: I will continue to play.

Thanks again guys.

If I ever change over to an Android handset, I will certainly miss Mortscript.

michoob
10th June 2011, 03:17 PM
@mitsi: lol, I hope you will not need any tool to manage SMS notifications with a new OS... actually, even though it is funny to play with MortScript, I think this kind of stuff should almost not exist with a well done OS... by the way, I think there are scripting languages under Android.

mitsi
10th June 2011, 03:24 PM
Michoob, I know what you mean, but isn't it fun to play with Mortscript? :D In fairness to Android, Blackberry, Microsoft etc they could not produce a handset that would suit everyone. It would be nice to think that you could input how long the vibrations should vibrate for, how many times a reminder appears on your screen etc etc!!! We're all different and that is why it is nice to be able to customise to suit ourselves :)

I hope you're right about a scripting program for Android. I will be moving to that when RIM allows emails to go through the Enterprise Server to non-Blackberry handsets.... It's coming later on this year. Don't you think it's getting a bit quiet on WM these days ;)

bbobeckyj
10th June 2011, 03:24 PM
So it doesn't play a tune, but will vibrate a bit then sleep for 10 minutes until some more vibrations! *I still don't understand why the playsound doesn't work. *Perhaps it is something to do with my file associations and what opens what extentions. :confused: I will continue to play.
I'm half heartedly tracking this thread on my phone.
If I understand your problem correctly, I think that the solution is that you need to tell the phone to turn on before it will play a sound. Try toggle screen on, and a brief sleep before the play sound command.

mitsi
10th June 2011, 03:27 PM
I'm half heartedly tracking this thread on my phone.
If I understand your problem correctly, I think that the solution is that you need to tell the phone to turn on before it will play a sound. Try toggle screen on, and a brief sleep before the play sound command.

Thanks, but I have tried clicking on a test mortscript which does nothing but:
playsound("\Application Data\Sounds\OldPhone.wav")

This is with the phone on, but it doesn't play a sound... :mad:

bbobeckyj
10th June 2011, 04:16 PM
Thanks, but I have tried clicking on a test mortscript which does nothing but:
playsound("\Application Data\Sounds\OldPhone.wav")

This is with the phone on, but it doesn't play a sound... :mad:

i had this problem a long time ago, I'm trying too remember what the problem was.
try copying the sound file to the windows folder and use play sound like this:
playsound ("\Alarm Clock.wav")

raving_nanza
10th June 2011, 06:13 PM
@mitsi

playsound("\Application Data\Sounds\XXXX.wav")
tried and yes, the script defo runs the .wav/.mp3 in application data folder.

upload the oldphone.wav here and ill test using that. eg i am testing with bootuphtc.wav and i am having no problems.

What version of MortScript are you running?
If you are not sure you can run this script

Message(MortScriptVersion())

the new 4.3 beta version is here (http://www.sto-helit.de/forum/download/file.php?id=265) (just incase your version is old)

try copying the sound file to the windows folder

i think you must specify the windows folder in script?? (not sure) eg: playsound ("\windows\XXXX.wav")

I don't think you need to be more real-time than that for SMS notifications...

i would prefer it in real-time regardless of battery ;) (however all those vibrations on the other hand are too much, that will defo drill the battery :D)


Rn

bbobeckyj
10th June 2011, 06:36 PM
playsound ("\alarm2.wav")

this works for me. i think that so long as the .wav is in the windows folder or in my documents, it will work.

After some testing though, I can't find a reason for a.wav to not play. Even if the path is incorrect an error sound still occurs.

raving_nanza
10th June 2011, 06:46 PM
i didnt test your playsound ("\XXXX.wav") but if you say it works ill agree ;)

i cant find a reason why it wont play either???
thats why i suggested mitsi to see what version he has, that could be the problem.


Rn

raving_nanza
10th June 2011, 06:47 PM
personally i always define the exact location

mitsi
11th June 2011, 08:24 AM
What version of MortScript are you running?
If you are not sure you can run this script

Message(MortScriptVersion())

the new 4.3 beta version is here (http://www.sto-helit.de/forum/download/file.php?id=265) (just incase your version is old)



raving_nanza, bbobeckyj & michoob I really appreciate you guys helping me.

I found that I had two problems. The first one is that I must have had an older version of MortScript. The second one is my OldPhone.wav must have been corrupt. I am having to use a different tone, but no worries :):)

It now all works!

By the way, I am not worried about the vibrations affecting my battery life as I nearly never get any texts anyway :D:D:D:D:D

Sad, but true. But IF I do, I will think of you guys!!!

mitsi
11th June 2011, 08:32 AM
Here's a working version, just in case anyone wants it While (1)
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
If (SMS>0)
Vibrate(100)
Sleep (100)
ToggleDisplay(on)
Sleep (100)
Vibrate(500)
playsound("\Application Data\Sounds\sms.wav")
Sleep (100)
Vibrate(100)
Sleep (3000)
Vibrate(500)
Sleep (100)
Vibrate(500)
Sleep (100)
Vibrate(500)
Sleep (600000)
EndIf
Sleep(3000)
EndWhile


It's not perfect though. If I get a text and don't read it, it will remind me in 10 minutes which is fine. With no unread texts, it polls every 3 seconds which again is fine. However, if I get a text and read it and then get another text within 10 minutes, I will not get any notifications until 10 minutes from the first text.... Um, I must think of a way around it....

The other problem is that if my phone is set to silent, it still vibrates....

mitsi
11th June 2011, 09:21 AM
Ok, so I have found the registry for "Silent" mode. I have tried to test it, but this does not work:

Vibrate=regread("HKCU","\ControlPanel\Sounds\RingTone0","Sound")
If (Vibrate eq *none*)
Message("Silent mode!")
EndIf


So, if my phone is on silent mode, I don't want it to vibrate or wake the screen up and it might as well also not play a sound. How can I integrate this into my script? :confused:

RoryB
11th June 2011, 11:59 AM
Need quotes around none:

Vibrate=regread("HKCU","\ControlPanel\Sounds\RingTone0","Sound")
If (Vibrate eq "*none*")
Message("Silent mode!")
EndIf

mitsi
11th June 2011, 12:01 PM
Need quotes around none:

Vibrate=regread("HKCU","\ControlPanel\Sounds\RingTone0","Sound")
If (Vibrate eq "*none*")
Message("Silent mode!")
EndIf


Thanks RoryB, that works :) Now on to the rest of it.... :cool:

mitsi
11th June 2011, 12:16 PM
Nearly there. Just need to sort out the problem that if two texts come through within 10 minutes after the first one has been read.... :D
While (1)
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
If (SMS>0)
Vibrate=regread("HKCU","\ControlPanel\Sounds\RingTone0","Sound")
If (Vibrate ne "*none*")
Vibrate(100)
Sleep (100)
ToggleDisplay(on)
Sleep (100)
Vibrate(500)
playsound("\Application Data\Sounds\sms.wav")
Sleep (100)
Vibrate(100)
Sleep (3000)
Vibrate(500)
Sleep (100)
Vibrate(500)
Sleep (100)
Vibrate(500)
playsound("\Application Data\Sounds\sms.wav")
Endif
Sleep (600000)
EndIf
Sleep(3000)
EndWhile

RoryB
11th June 2011, 12:32 PM
It is ne instead of neq for not equal

The reason you do not get your second notice is the sleep for 10 minutes does not let you test for another message.

You need to do something like this in place of your sleep. It wil check for a change in the message count every second and skip to next reminder if it changes. SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
Repeat(10)
Sleep(1000)
If( SMS eq regread("HKCU","\System\State\Messages\sms\Unread","Count"))
# do nothing
Else
Break
Endif
End repeat
I do not have the manual handy. So the code may not be correct, but this gets the idea across.

mitsi
11th June 2011, 12:51 PM
It is ne instead of neq for not equal

The reason you do not get your second notice is the sleep for 10 minutes does not let you test for another message.

You need to do something like this in place of your sleep. It wil check for a change in the message count every second and skip to next reminder if it changes. SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
Repeat(10)
Sleep(1000)
If( SMS eq regread("HKCU","\System\State\Messages\sms\Unread","Count"))
# do nothing
Else
Break
Endif
End repeat
I do not have the manual handy. So the code may not be correct, but this gets the idea across.

Thanks RoryB. I had spotted the "neq/ne" error and changed the script.

I can see what your suggestion could do, but I'm not sure how to apply it to my script. Does this check 10 times, once every second? So will it only check for 10 seconds? Where would it go in my script? In place of the "Sleep (600000)"?

Would you mind putting it in my script please? Sorry to be a pain...

RoryB
11th June 2011, 01:38 PM
Thanks RoryB. I had spotted the "neq/ne" error and changed the script.

I can see what your suggestion could do, but I'm not sure how to apply it to my script. Does this check 10 times, once every second? So will it only check for 10 seconds? Where would it go in my script? In place of the "Sleep (600000)"?

Would you mind putting it in my script please? Sorry to be a pain...

I am working on a small screen so it is difficult.

Yes, replace your sleep(60000)

You can change the 1 second to 1 minute or the repeat 10 to repeat 60 or whatever you want to check as often and for however long you want.

mitsi
11th June 2011, 04:37 PM
I am working on a small screen so it is difficult.

Yes, replace your sleep(60000)

You can change the 1 second to 1 minute or the repeat 10 to repeat 60 or whatever you want to check as often and for however long you want.

Thanks RoryB, it works a treat. :cool: Here it is:

While (1)
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
If (SMS>0)
Vibrate=regread("HKCU","\ControlPanel\Sounds\RingTone0","Sound")
If (Vibrate ne "*none*")
Vibrate(100)
Sleep (100)
ToggleDisplay(on)
Sleep (100)
playsound("\Application Data\Sounds\sms.wav")
Vibrate(500)
Sleep (100)
Vibrate(100)
Sleep (3000)
Vibrate(500)
Sleep (100)
Vibrate(500)
Sleep (100)
Vibrate(500)
playsound("\Application Data\Sounds\sms.wav")
Endif
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
Repeat(5000)
Sleep(3000)
If( SMS eq regread("HKCU","\System\State\Messages\sms\Unread","Count"))
# do nothing
Else
Break
Endif
Endrepeat
EndIf
Sleep(3000)
EndWhile

RoryB
11th June 2011, 04:43 PM
You actually do not need the second sms = statement
While (1)
SMS=regread("HKCU","\System\State\Messages\sms\Unread","Count")
If (SMS>0)
Vibrate=regread("HKCU","\ControlPanel\Sounds\RingTone0","Sound")
If (Vibrate ne "*none*")
Vibrate(100)
Sleep (100)
ToggleDisplay(on)
Sleep (100)
playsound("\Application Data\Sounds\sms.wav")
Vibrate(500)
Sleep (100)
Vibrate(100)
Sleep (3000)
Vibrate(500)
Sleep (100)
Vibrate(500)
Sleep (100)
Vibrate(500)
playsound("\Application Data\Sounds\sms.wav")
Endif
Repeat(5000)
Sleep(3000)
If( SMS eq regread("HKCU","\System\State\Messages\sms\Unread","Count"))
# do nothing
Else
Break
Endif
Endrepeat
EndIf
Sleep(3000)
EndWhile

mitsi
11th June 2011, 04:52 PM
You actually do not need the second sms = statement


Ok, thanks!

sudist
11th June 2011, 07:37 PM
@mitsi

You can also use the Notification Queue to loop your script every x minute, with the command RUNAT
Then , the script is not running all the time (for example when the time is 23H30 you can let it jump to 7h00 in the morning)

mitsi
13th June 2011, 06:44 AM
@mitsi

You can also use the Notification Queue to loop your script every x minute, with the command RUNAT
Then , the script is not running all the time (for example when the time is 23H30 you can let it jump to 7h00 in the morning)

Thanks sudist, good idea.

jwoegerbauer
19th June 2011, 02:52 PM
Thought I should share this function.

Sub IsActiveSyncMode()
Local(key,key2,subkey,value,data)
key="Drivers\Active"
ForEach subkey In RegSubKeys("HKLM",key)
key2=key\subkey
ForEach value,data In RegValues("HKLM",key2)
If(value EQ "Key")
If(data EQ "\Drivers\USB\FunctionDrivers\Serial_Class")
ExitSub(1)
EndIf
EndIf
Sleep 10
EndForEach
Sleep 10
EndForEach
Return(0)
EndSub

Usage example:
ErrorLevel("warn")
Include("SubRoutines\IsActiveSyncMode.mscr")
Message(@IsActiveSyncMode())

RoryB
21st June 2011, 08:17 PM
Thread started today for MortScripts that can be used in CHTS (http://forum.xda-developers.com/showthread.php?t=792178). They started as a supplement to CHTS, but they can be used outside it too.

So far I have radio band changer and sound profile changer scripts.

MortScripts to toggle settings (http://forum.xda-developers.com/showthread.php?t=1134312)

sudist
24th June 2011, 07:03 AM
I think I never saw a sleep fonction overhere....
First : create a script to kill your media player (tcpmp, wmp, etc)
kill ("Player.exe")
Second : copy this script (Change values like you wish, my screensize 320x240)
RemoveNotifications ("\Program Files\Mortscript\scripts\KillPlayer.mscr")
run ("\windows\menu démarrer\programmes\voir today.lnk")
setchoiceentryformat("47","30")
Choice("Fonction Sleep","Fait votre choix pour determiner le sleep"," 10 Minutes"," 15 Minutes "," 20 Minutes"," 25 Minutes","<-Exit")
case(1)
RunAt ( Timestamp()+600, "\Program Files\Mortscript\scripts\KillPlayer.mscr")
ToggleDisplay (FALSE)
case(2)
RunAt ( Timestamp()+900, "\Program Files\Mortscript\scripts\KillPlayer.mscr")
ToggleDisplay (FALSE)
case(3)
RunAt ( Timestamp()+1200, "\Program Files\Mortscript\scripts\KillPlayer.mscr")
ToggleDisplay (FALSE)
case(4)
RunAt ( Timestamp()+1800, "\Program Files\Mortscript\scripts\KillPlayer.mscr")
ToggleDisplay (FALSE)
case(5)
exit
endchoice
exit
When you run the script, you should get something like this:

http://img833.imageshack.us/img833/6388/capture001.png (http://imageshack.us/photo/my-images/833/capture001.png/)

raving_nanza
26th June 2011, 11:06 PM
mortstcipt to run total commander and view the storage card folder?

or any folder :D

thanks


Rn

jwoegerbauer
27th June 2011, 08:57 AM
See here: http://www.ghisler.ch/wiki/index.php/Command_line_parameters

raving_nanza
27th June 2011, 09:07 AM
thanks, ill try it later :)


Rn

raving_nanza
27th June 2011, 03:09 PM
dudes, why aint this working??
got a little bug in my rom, i forgot to cook the app.dat for xdafacebook so i need a mortscript to copy the files, a quick fix..

keep getting error for comma missing??

when checking the new xdafacebook folder, it is empty :confused:
(and all files are in the windows folder)

MkDir ("\Program Files\XDAFacebook")
Copy ("\Program Files\XDAFacebook\OpenNETCF.Configuration.dll","\Windows\OpenNETCF.Configuration.dll")
Copy ("\Program Files\XDAFacebook\OpenNETCF.dll","\Windows\OpenNETCF.dll")
Copy ("\Program Files\XDAFacebook\Microsoft.WindowsMobile.Samples. Location.dll","\Windows\Microsoft.WindowsMobile.Samples.Location. dll")
Copy ("\Program Files\XDAFacebook\FBEntities.dll","\Windows\FBEntities.dll")
Copy ("\Program Files\XDAFacebook\Newtonsoft.Json.Compact.dll","\Windows\Newtonsoft.Json.Compact.dll")
Copy ("\Program Files\XDAFacebook\logo.ico","\Windows\logo.ico")
Copy ("\Program Files\XDAFacebook\XDAFacebook.exe","\Windows\XDAFacebook.exe")
Copy ("\Program Files\XDAFacebook\ICSharpCode.SharpZipLib.dll","\Windows\ICSharpCode.SharpZipLib.dll")
Copy ("\Program Files\XDAFacebook\XFSettings.dll","\Windows\XFSettings.dll")
Copy ("\Program Files\XDAFacebook\XFSenseUI.dll","\Windows\XFSenseUI.dll")
Copy ("\Program Files\XDAFacebook\XFItemControls.dll',"\Windows\XFItemControls.dll")
MkDir ("\Program Files\XDAFacebook\Resources")
Copy ("\Program Files\XDAFacebook\Resources\XFPanelHome.png","\Windows\XFPanelHome.png")
Copy ("\Program Files\XDAFacebook\Resources\albums.png","\Windows\albums.png")
Copy ("\Program Files\XDAFacebook\Resources\alphabar.png","\Windows\alphabar.png")
Copy ("\Program Files\XDAFacebook\Resources\chat.png","\Windows\chat.png")
Copy ("\Program Files\XDAFacebook\Resources\donate.gif","\Windows\donate.gif")
Copy ("\Program Files\XDAFacebook\Resources\events.png","\Windows\events.png")
Copy ("\Program Files\XDAFacebook\Resources\feeds.png","\Windows\feeds.png")
Copy ("\Program Files\XDAFacebook\Resources\friends.png","\Windows\friends.png")
Copy ("\Program Files\XDAFacebook\Resources\header.png","\Windows\header.png")
Copy ("\Program Files\XDAFacebook\Resources\loading.png","\Windows\loading.png")
Copy ("\Program Files\XDAFacebook\Resources\logo.png","\Windows\logo.png")
Copy ("\Program Files\XDAFacebook\Resources\notes.png","\Windows\notes.png")
Copy ("\Program Files\XDAFacebook\Resources\places.png","\Windows\places.png")
Copy ("\Program Files\XDAFacebook\Resources\profile.png","\Windows\profile.png")
Copy ("\Program Files\XDAFacebook\Resources\requests.png","\Windows\requests.png")
Copy ("\Program Files\XDAFacebook\Resources\updatestatus.png","\Windows\updatestatus.png")
MkDir ("\Program Files\Xdafaxebook\Skins")
MkDir ("\Program Files\Xdafaxebook\Skins\hungelt8")
Copy ("\Program Files\Xdafaxebook\Skins\hungelt8\ProfileTabs.png", "\Windows\ProfileTabs.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\albums.png","\Windows\albums.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\back.png","\Windows\back.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\chat.png","\Windows\chat.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\events.png","\Windows\events.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\"feeds.png","\Windows\feeds.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\friends.png","\Windows\friends.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\header.png","\Windows\header.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\iconThumb.png","\Windows\iconThumb.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\image.png","\Windows\image.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\loading_bg.png","\Windows\loading_bg.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\notes.png","\Windows\notes.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\notifications_bg. png","\Windows\notifications_bg.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\"places.png","\Windows\places.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\"profile.png","\Windows\profile.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\refresh.png","\Windows\refresh.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\requests.png","\Windows\requests.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\selected-tab.png","\Windows\selected-tab.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\unselected-tab.png","\Windows\unselected-tab.png")
Copy ("\Program Files\XDAFacebook\Skins\hungelt8\updatestatus.png","\Windows\updatestatus.png")
Copy ("\Program Files\XDAFacebook\Resources\"inbox.png","\Windows\inbox.png")
Copy ("\Program Files\XDAFacebook\Resources\splash.png,"\Windows\splash.png")

thamks


Rn

jwoegerbauer
27th June 2011, 03:41 PM
This line is wrong:

Copy ("\Program Files\XDAFacebook\XFItemControls.dll',"\Windows\XFItemControls.dll")

You used a ' single quote instead of a " double quote.

RoryB
27th June 2011, 03:49 PM
Copy is source to destination.

Try changing your copy lines to be copy("\windows\xxx.xxx","\Program Files\XDAFacebook\xxx.xxx")

-----------------------------

I used to use zip files for this function so there is only one file in \windows and when unzipped it puts the files in the correct folder.

Homer-S
27th June 2011, 04:26 PM
Hello,

I have a question. How can I force the operator setup to start with mortscript and how can I choose within this setup a defined operator?

At the moment I have a wait routine and hope the operator setup after a sim change will appear in this time and then I make a click on the usual position?!

Thanks

raving_nanza
27th June 2011, 05:15 PM
Copy ("\Program Files\XDAFacebook\XFItemControls.dll',"\Windows\XFItemControls.dll")

cheers, stupid pc keyboard wont switch to uk, stuck on us - wont change in regional either :mad:

copy("\windows\xxx.xxx","\Program Files\XDAFacebook\xxx.xxx")

will try it dude, thanks :D

jwoegerbauer
28th June 2011, 03:04 PM
@RoryB,

IMO in the script example you posted here http://forum.xda-developers.com/showpost.php?p=7901163&postcount=3650 (http://forum.xda-developers.com/showpost.php?p=7901163&postcount=3650) is a massive bug:

ForEach xkey, xvalue in inifile( inifile, "Settings" )
[xkey]=xvalue
# The [] around xkey tells the script to define a variable with the name equal to the value of xkey
EndForEach

I believe it should be iniSections instead.

RoryB
28th June 2011, 07:12 PM
@RoryB,

IMO in the script example you posted here http://forum.xda-developers.com/showpost.php?p=7901163&postcount=3650 (http://forum.xda-developers.com/showpost.php?p=7901163&postcount=3650) is a massive bug:

ForEach xkey, xvalue in inifile( inifile, "Settings" )
[xkey]=xvalue
# The [] around xkey tells the script to define a variable with the name equal to the value of xkey
EndForEach

I believe it should be iniSections instead.Actually it should be iniKeys and I fixed the original post. Thank you for catching that. It was correct in my phone, must have grabbed an older version to post.

jwoegerbauer
28th June 2011, 08:13 PM
Haha, you are absolutely right, I also was mistaken. BTW, that's the coding I actually use in one of my projects to speed up things:

#To get rid of the individual IniRead() lines with this foreach group
#After an idea by RoryB http://forum.xda-developers.com/showpost.php?p=7901163&postcount=3650

Local(inifile,section,key,value)

inifile=XXXXXXXXX
If(FileExists(inifile))
ForEach section In IniSections(inifile)
ForEach key,value In IniKeys(inifile,section)
# The [] around key tells the script to define a variable with the name equal to the value of key
If(value NE "")
[key]=value
EndIf
Sleep 50
EndForEach
Sleep 50
EndForEach
EndIf

Clear(inifile)
Clear(section)
Clear(key)
Clear(value)

For me it seems this solution is a bit faster than querying values via RegRead() - which again is really faster than IniRead() - and considering the amount of RAM used it makes no difference, because the location of the array built - using your method - is RAM, as it is with the registry itself. And the most advantage in doing it such way, I see in fact registry isn't flooded.

RoryB
28th June 2011, 09:15 PM
True, and with the iniEditor script you can create an interface for people adjusting the ini file values with explanation of the values. see my sig

raving_nanza
29th June 2011, 06:28 PM
trying to add weather to my rom, basicly everything is set up, but all i need now is this script to work.. keep getting an error :confused:

(error in line 1, comma missing or closing paranthesis)

If(RegValueExists( "HKCU", "Software\emerym\Weather\Current\", Partly Cloudy ))
Copy ("\Windows\todaycloud.png","\program files\rltoday\default\currentweather.png")
EndIf
redrawtoday

thanks


Rn

jwoegerbauer
29th June 2011, 06:33 PM
This line

If(RegValueExists( "HKCU", "Software\emerym\Weather\Current\", Partly Cloudy ))

contains 2 errors: should be corrected as following

If(RegValueExists( "HKCU", "Software\emerym\Weather\Current", "Partly Cloudy"))

raving_nanza
29th June 2011, 06:47 PM
thanks for quick reply dude :D (appreciated)

ok, last one now :)

no error but the .png is not being copied
(.png is in the windows folder and the registry does exist - "current" is a string and "partly cloudy" is its contents..... if this helps :))

If(RegValueExists( "HKCU", "Software\emerym\Weather\Current", "Partly Cloudy"))
Copy ("\Windows\todaycloud.png","\program files\rltoday\default\currentweather.png")
EndIf
redrawtoday

thanks

jwoegerbauer
29th June 2011, 07:34 PM
If the key you are querying is named "Current" and its value must be "Partly Cloudy" in order processing should take place, then try as following:

If("partly cloudy" EQ ToLower(RegRead("HKCU","Software\emerym\Weather","Current")))
Copy("\Windows\todaycloud.png","\program files\rltoday\default\currentweather.png")
EndIf

raving_nanza
29th June 2011, 07:42 PM
you da man dude! :D:D

*at first i thought, shizz not again but then deleted the .png and tried again and it works like a charm ;)

(ill click thanks button later and add you to the thanks list on my rom thread, just got to do this script for 40+ weather types LOL)


THANKS!


Rn

raving_nanza
29th June 2011, 07:54 PM
ive had to put the command

delete("\program files\rltoday\default\currentweather.png")

at the start of the script for this script to work

for some reason it wont overwrite the previous currentweather.png in rltoday folder..

but all is working nicely now :D


Rn

RoryB
29th June 2011, 09:12 PM
Did you try Copy("\Windows\todaycloud.png","\program files\rltoday\default\currentweather.png", TRUE) to force overwrite existing file?

raving_nanza
29th June 2011, 09:22 PM
sorry, lol... me again :rolleyes:

what i need now is totaly differant, i need a script that will write a registry string but via user input..

eg, i need it to write a string called "location?"

the contents of "location?" should be edited by the user and saved, a simple input box that saves the text to the "location?" string

*i dont know how to create this but i know it is do-able :)

(iv already tried doing this with jmlmenusense but it is not writing the contents to the registry, but can read it which is strange :confused:)

*btw this is the last part of the weather and then 100% complete :D

thanks


Rn


@RoryB

no dude, i have DELETE at the start of the script, everything that follows is IF & ENDIF so its all good ;)

RoryB
29th June 2011, 09:49 PM
I am away from my files, but I believe it is

location = input("Enter your location: ")

raving_nanza
29th June 2011, 09:57 PM
yeah dude,

that brings up the edit box i need :)
(glad someone understood what i meant :D lol)

ok, so how would i go about saving what ever is typed into the edit box as a registry string?

also, if it is edited again by the user - it will overwrite the previously saved string..


"stay with me dude, 95% complete now :D"


Rn

RoryB
29th June 2011, 10:13 PM
Oh BTW I meant use the TRUE instead of deleting the file first. Try removing that line and then use copy with the TRUE.

You would use regwrite

If it is a string it would be regwritestring("HKCU", "Software\emerym\Weather\Current", "Partly Cloudy", location) would write the name of the location answered in to the registry value "Partly Cloudy" as a string

raving_nanza
29th June 2011, 10:51 PM
cheers RoryB,

now you da man now dude! :D lol

i DELETE the file at the start of the script so i do not need the TRUE.. otherwise i need 40+ TRUE which meens the file size would be smaller with DELETE :)


anyway...


location = input("Please enter your location: ")
regwritestring("HKCU", "Software\emerym\", "Location?", location)
redrawtoday

this works perfect now dude, thank you both for your help!!


http://forum.xda-developers.com/picture.php?albumid=960&pictureid=13749

weather is now 100% working:


THANKS!


Rn


EDIT:

i spammed the thanks button for both of you :D
cheers dudes!

motoes400
30th June 2011, 02:04 PM
Greetings!

I am working with a Motorola ES400 running Windows mobile 6.5. My question involves Mortscript and I couldn't find anyone discussing es400/mscr.

This ES400 has multiple users. It is locked down to prevent users from using anything except 5 different applications and a Tools button. (appcenter)

The issue I have is that the apps are buggy *if* rapidly clicked while loading. Instances will load behind each other and prevent functionality from the top of the stack. Ideally, the source for the app itself should prevent this, but isn't available to me.

i.e. The phone has 5 different app icons, I'll refer to them as (A,B,C,D,E)

If a user clicks 'A', the 'A' app loads after approximately 1-2 seconds and all is well. The app fullscreens and the user cannot minimize to click additional icons.

However, if a user clicks 'A' and subsequently clicks B/C/D/E before A resolves, there will be 5 or more applications running.

Each icon on the phone interface points to a specific mortscript which will control its loading (Or so I thought). :D

Here is what I have so far. Checks are needed to ensure the first app clicked is the only one open when everything resolves.

AApp= "\Program Files\A_App\A_App.exe"

If(WndExists("A_App"))
While(WndExists("A_App"))
Close("A_App")
EndWhile
EndIf
If(WndExists("B_APP"))
While(WndExists("B_APP"))
Close("B_APP")
EndWhile
EndIf
If(WndExists("C_APP"))
While(WndExists("C_APP"))
Close("C_APP")
EndWhile
EndIf
Run(AApp)
Exit

Any help or suggestions are appreciated.

jwoegerbauer
30th June 2011, 03:13 PM
That's how I'ld try to solve the problem you mentioned (note that this is only a code snippet):

Local(ap,A_App,B_App,C_App,cnt)

A_App="A.exe"
B_App="B.exe"
C_App="C.exe"

#get processname of active (topmost) window
ap=ActiveProcess(0)

#terminate processes except process that relates to the topmost window
If(ap NE A_App)
cnt=0
While((cnt<10)&&ProcExists(A_App))
Kill(A_App)
Sleep 500
cnt+=1
EndWhile
EndIf
If(ap NE B_App)
cnt=0
While((cnt<10)&&ProcExists(B_App))
Kill(B_App)
Sleep 500
cnt+=1
EndWhile
EndIf
If(ap NE C_App)
cnt=0
While((cnt<10)&&ProcExists(C_App))
Kill(C_App)
Sleep 500
cnt+=1
EndWhile
EndIf

Clear(A_App)
Clear(B_App)
Clear(C_App)
Clear(cnt)
Clear(ap)

RoryB
30th June 2011, 05:20 PM
I think the problem is that the window does not exist yet and the user can still "see" the menu to tap another choice.

Is it one MortScript called by each icon with a different argument or is it 5 separate scripts?

You could have a status message pop up as soon as someone taps the icon to state opening program A and that way you hide the other icons. You can then hide the status message after so many seconds to show the program.

motoes400
30th June 2011, 08:29 PM
That's how I'ld try to solve the problem you mentioned (note that this is only a code snippet):

Local(ap,A_App,B_App,C_App,cnt)
...
Clear(ap)

Thanks for the suggestion! I tried adding the Run() process above the ap=ActiveProcess(0) as well as before the Clear(). Clicking a single app a few times works well and limits to one. Clicking all the apps, however, allowed multiple copies to be loaded.

One detail I should have mentioned is that 2 of the app icons start processes with identical names. The apps have few differences, are loaded from different install directories, yet have the same Process/Window name.

I will attempt to better explain.

App Apple - process/window 'Apple' 2.1mb
App Apple 2 - process/window 'Apple' 2.25mb
App Boy - process/window 'Boy' 1.9mb
App Boy 2 - process/window 'Boy' 2.1mb
App Cat - process/window 'Cat' 2mb


Is it one MortScript called by each icon with a different argument or is it 5 separate scripts?

You could have a status message pop up as soon as someone taps the icon to state opening program A and that way you hide the other icons. You can then hide the status message after so many seconds to show the program.

Thanks for the input! I tried something like:

A_App="\Program Files\app\A_App.exe"
Run(A_App)
SleepMessage(5,"Loading App_A, please wait",1)

This worked fine for 1 copy, but when clicking the icons quickly enough, it allowed multiple copies to open.

I currently use 5 different Mortscripts, but I initially started with one. I thought it would be cleaner to use an array and foreach app, prevent new ones. Alas, now I have 5, but I'm willing to modify these to the cleanest way to prevent human error/fat fingers.

I believe the challenge here is to get around the identically named proc/wnd names simultaneously running.

Thanks for both replies and apologies for noobing it up.

RoryB
30th June 2011, 08:41 PM
Do you have to use icons? You could use a choice dialog to let them pick which program to run and therefore they could only pick one.

ironhead65
1st July 2011, 12:51 PM
Hello all,

I've been working on an Alarm Clock, using Mortscripts. So far, it works VERY well. As soon as I get something finished up, I will post it here.

Features:
-Up to 10 independent alarms
-DOW (Day of Week) selector
-Event time
-Starting system volume (not working yet) (Vibrate to max)
-Original volume is saved, so after you hit dismiss your phone's volume is set BACK to the volume it was set for prior to the alarm
-Vibrate additional to music
-MP3 to play
-Names
-Alarm Enable / Disable (if you go on vacation, you do not need to have the work alarm on)
-Some integration with Billboard v1.10
-Snooze

Features needed to be added:
-right now, only starts playing music at a LOW volume, then every 10 seconds volume increases by 5%...want to make this selectable between this and just play at ONE volume (system volume)
-Start volume
-One time alarm function (so far, only recurring)
-working on a program to read back things from the notification queue (to display on BillBoard)
-Variable time for Snooze
-Re-enable time...that is, if you know you are on vacation for a week, set the alarm disabled for 1 week. Then it will turn back on by itself (sometimes I forget to turn alarms back on the day before I must return to work).
-Maybe add a vibrate after so much time has past...so if you won't hit snooze or dismiss after say...2 minutes, the phone starts to vibrate

I've kind of run into a snag. I can't figure out how through tools or registry entries, you can tell if Windows Media Player Mobile is set for repeat or not. I found a few tools that let me control the volume and turn shuffle/repeat on / off, but how can I tell that it IS set on/off? I tried to do the "mouseclick" or "sendrightsoft" then navigate the menus...but those commands do not seem to function with Windows Media Player.

Also, I've been using this in it's v0.4 state for about 4 weeks. So far the only time it has not woken me up was when I set the alarm disable improperly. I've been enjoying getting up to soft music that gradually gets louder. Typically this will wake me before my wife, which gives me a lot of points!

Thanks for any ideas!

--Ironhead

jwoegerbauer
1st July 2011, 05:48 PM
One detail I should have mentioned is that 2 of the app icons start processes with identical names. The apps have few differences, are loaded from different install directories, yet have the same Process/Window name.

I will attempt to better explain.

App Apple - process/window 'Apple' 2.1mb
App Apple 2 - process/window 'Apple' 2.25mb
App Boy - process/window 'Boy' 1.9mb
App Boy 2 - process/window 'Boy' 2.1mb
App Cat - process/window 'Cat' 2mb

I currently use 5 different Mortscripts, but I initially started with one. I thought it would be cleaner to use an array and foreach app, prevent new ones. Alas, now I have 5, but I'm willing to modify these to the cleanest way to prevent human error/fat fingers.

I believe the challenge here is to get around the identically named proc/wnd names simultaneously running.



I believe your current thinking points to the right direction, if you state "I currently use 5 different Mortscripts": each of these scripts could remember itself in an INI-file, which again could be investigated by the other 4 scripts.

IMO, the INI should have a section [APPS] holding the 5 applications' name and their respective full filepathname, ex.

[APPS]
App_Apple_2.1MB=<fullfilepathname here>
App_Apple_2.25MB=<fullfilepathname here>
App_Boy_1.9MB=<fullfilepathname here>
App_Boy_2.1MB=<fullfilepathname here>
App_Cat_2.0MB=<fullfilepathname here>

and an additional section [APP_CURRENT] holding the application name, maintained (called) by the last started script, ex.

[APP_CURRENT]
Current=App_Cat_2.0MB

Now, each script when it starts, could search the INI for an already running application and close it before starting a new application, ex.

#APP_Apple_2.1MB.mscr

Local(cwf,inifile,current,key,value,cnt,stopsearch ,fpn)
cwf=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")

inifile="<fullfilepathname here>"
current=IniRead(INI,"APP_CURRENT","Current")

If((NOT IsEmpty(current))&&(current NE ""))
stopsearch=0
ForEach key,value In IniKeys(inifile,APPS)
If(value NE "")
If(key EQ current)
fpn=value
cnt=0
While((cnt<10)&&ProcExists(value))
Kill(value)
Sleep 500
cnt+=1
EndWhile
stopsearch=1
EndIf
EndIf
If(stopsearch)
Break
EndIf
Sleep 50
EndForEach
EndIf

Run(fpn)
IniWrite(inifile,"APP_CURRENT","Current",SystemPath("ScriptName"))

Exit
KillScript(cwf)

RoryB
1st July 2011, 06:12 PM
Reading through the manual:

4.3 Multiple instances and aborting scripts
MortScript can run in multiple instances, but only once for each script. If an already running script is run a second time, an open dialog of that script (e.g. Choice, Message, ...) will be activated. If the script doesn't show any windows, nothing will happen. If you want to terminate running scripts, you can use ScriptProcExists and KillScript. See also informations in 9.21.7 End a running script (KillScript).

Based on this if you use a single script to start the programs and use arguments in the different links represented by the icons you should only be able to run the script one time. You could use runwait to make the script wait for the program to exit prior to it stopping and that way they could not go to the today page and start another program as long as the first program is still running.

*APP_Apple_2.1MB.lnk*
75#\windows\mortscript.exe \windows\starter.mscr \windows\APP_Apple_2.1MB.exe

#starter.mscr
program = argv[1]
Runwait(program)

raving_nanza
4th July 2011, 01:08 PM
hi dudes, was just wondering :rolleyes:

how to get opera 10 to run and go to a specific url or make it use google?

eg,

Google = input("Search: ")
regwritestring("HKCU", "Software\Rn\", "Google", Google)

#*writes a registry for what you want to search for "XXXXXXXX"

run("\program files\opera mobile 10\opera10-armv4i.exe")
WaitForActive("Opera Mobile 10",20)
#*maybe add an IF to switch to opera incase opera is open in the background so there is no wait ENDIF

regreadstring("HKCU", "Software\Rn\", "Google?", Google)

#*COPY "XXXXXXXX"
#*TAB TO GOOLE IN OPERA 10
#*PASTE XXXXXXXX
#*GO

raving_nanza
4th July 2011, 01:10 PM
double post... silly xda

michoob
4th July 2011, 01:54 PM
@raving_nanza: extracted from IPTWeather, might help you:
defaultBrowser = Replace(Replace(RegRead("HKCR", "http\Shell\Open\Command", "Default"), " %1", ""), """", "")
RunWait(defaultBrowser, "http://www.accuweather.com/world-index.asp?partner=rainmeter&traveler=0")

raving_nanza
4th July 2011, 02:09 PM
just wrote the script but thanks for help :D

Google = input("Search: ")
regwritestring("HKCU", "Software\Rn\", "Google?", Google)
run("\program files\Opera Mobile 10\Opera10-armv4i.exe")
WaitForActive("Opera Mobile 10",20)
MouseClick( "Opera Mobile 10", 400, 30 )
regreadstring("HKCU", "Software\Rn\", "Google?", Google)
Sendkeys("Opera Mobile 10", Google)
SendCr

this will save the "search" into the registry
launch opera10 - click google
then pastes the saved registry "search" and go!

FOR WVGA DEVICE ONLY!!! = 400, 30

enjoy peeps :cool:


Rn

raving_nanza
4th July 2011, 02:22 PM
hi dudes, lol

if i click cancel on:

Google = input("Search: ")

how to terminate the script so it actually cancels the rest of the script??

eg something like:

Google = input("Search: ")
IF("cancel")
terminate("mortscript.exe")
ENDIF
regwritestring("HKCU", "Software\Rn\", "Google?", Google)
ete etc etc etc


Rn

michoob
4th July 2011, 03:00 PM
@raving_nanza:
Google = input("Search: ")
IF(Google eq "")
Exit
ENDIF
regwritestring("HKCU", "Software\Rn\", "Google?", Google)
ete etc etc etc

raving_nanza
4th July 2011, 03:22 PM
if(google eq "")
exit
endif

cheers dude, working as expected now, thanks for quick reply


Rn

Telemachus
5th July 2011, 07:05 PM
Reading through the manual:

4.3 Multiple instances and aborting scripts
MortScript can run in multiple instances, but only once for each script. If an already running script is run a second time, an open dialog of that script (e.g. Choice, Message, ...) will be activated.

I am using an old IPAQ as the media player for an MP3 doorbell, using mortplayer as the media device, since it has the convenient option to stop playing at the end of the track, and move on to the next track. Using a simple lnk to mortplayer.exe "play" and assigning that to a hardware button, which is then hardwired to the external button outside the house, it works great to play a random MP3 as the doorbell.

The problem I run into is that if someone pushes the button outside twice, it immediately starts and stops the queued MP3.

Based on what you stated, I would think the easiest fix for this would be to have the hardware button mapped to a mortscript that will only play if the current file is not already being played, or if the mortplayer window has not yet closed.

I would rather keep mortplayer open, and not have to close it after every file. Is there a command that would interrogate whether or not the program is currently PLAYING, and if so, hold the script?

Thanks!

RoryB
5th July 2011, 07:24 PM
I do not use MortPlayer. Does it set a registry value to tell that it is playing versus stopped? If so, you could check that value.

If not, you would probably need it to exit after playing if that is possible. Then you could use if(procexists("MortPlayer.exe"))

Telemachus
5th July 2011, 07:30 PM
I do not use MortPlayer. Does it set a registry value to tell that it is playing versus stopped? If so, you could check that value.

If not, you would probably need it to exit after playing if that is possible. Then you could use if(procexists("MortPlayer.exe"))

Now that I think about it, mortplayer has an accompanying program called MPNOTIFY, and that is what I am using to control the player. For instance, MPNOTIFY.exe "PLAY" hits play on Mortplayer, and then I think closes itself. So maybe the easiest would be to have mortscript run MPNOTIFY.exe, and then hold for 15 seconds. As long as my doorbell tones are less than 15 seconds, I shouldn't run into a problem.

What will happen if the script is run again by another button push while in the 15 second waiting period?

RoryB
5th July 2011, 08:23 PM
If pressing the button starts a mortscript that runs MPNotify.exe, then sleeps for 15 seconds and then exits, pressing the button before the first script exists should do nothing.

Does MPNotify have a restart or stop command line?

You could have the script that gets started by the button press first stop MP and then start it. So if after the 15 seconds and before the song stops someone presses the button again, the song would stop and MP would start again. Or maybe there is a rewind to the beginning of the song that if there is a song playing it would rewind and if not the next song would start.

Telemachus
5th July 2011, 09:18 PM
MPnotify has some basic parameters, only ones I have figured out are "play", "next", and "stop"

I had previously created a link called Play.lnk that calles up MPNotify.exe "play" and that is what I had mapped to a button, leaving the problems of multiple presses as mentioned.

Now, using this simple script:

Run ("Program Files\Mortplayer\Play.lnk")
Sleep 15000

and linking that script to a button, it works well. Another button press does nothing until the 15 seconds are up, so THANK YOU.

But now I am hungry for more! I should be able to add the parameter right in mortscript, correct.

ie:

Run ("Program Files\Mortplayer\MPNotify.exe [,PLAY]")

or something to that effect? I don't understand the parameter section of the manual...

RoryB
5th July 2011, 09:23 PM
You are close

Run ("Program path and name","argument")


Run ("Program Files\Mortplayer\MPNotify.exe","PLAY")

Telemachus
5th July 2011, 09:38 PM
Thank you for your help with this. When I do that, I get an error in Mortplayer that "PLAY" not found, meaning that

Run ("Program Files\Mortplayer\MPNotify.exe","play")

is actually asking it to open play a file named "play."

The lnk file that I use, when opened up in notepad, shows this:

47#"\Program Files\MortPlayer\MPNotify.exe" "play"

and that works just fine!

RoryB
5th July 2011, 10:00 PM
Stumped. Maybe

Run ("Program Files\Mortplayer\MPNotify.exe",""PLAY"")

or

Run ("Program Files\Mortplayer\MPNotify.exe","""PLAY""")

or

Run ("Program Files\Mortplayer\MPNotify.exe",""""PLAY"""")

Telemachus
5th July 2011, 10:12 PM
LOL, I'm a moron. I realized that I had changed the script to say

Run ("Program Files\Mortplayer\Mortplayer.exe","play")

which is why it was looking for that file.

Instead, it needed to be:

Run ("Program Files\Mortplayer\MPNotify.exe","play")

which works just fine.

The 15 second waiting period works, but does limit the length of song that can be used as a doorbell. I think either using your idea of using a "Next" parameter to skip to the next song if they push it multiple times, or trying to determine if any registry file is added while Morplayer is playing will be the way to go.

Thanks again.

Telemachus
6th July 2011, 08:02 AM
This does all that I need it to, thanks to your ideas:


#First test to see if Mortplayer is open, and first stop
#then play the song, so that mutiple button pushes won't stop the song.

if(procexists("MortPlayer.exe"))
Run ("\Program Files\Mortplayer\mpnotify.exe" , "stop")
Run ("\Program Files\Mortplayer\mpnotify.exe" , "play")

#otherwise, if Mortplayer not running, open it up and play.

else

Run ("\Program Files\Mortplayer\mpnotify.exe" , "play")

endif

michoob
6th July 2011, 08:26 AM
Why not just the following instead of any testing?
RunWait("\Program Files\Mortplayer\mpnotify.exe" , "play")
Of course, that would only work if MPNotify keeps on running while the player is on...

Telemachus
6th July 2011, 06:49 PM
MPnotify turns on momentarily to execute a command on the Mortplayer app itself, and then closes.

I was working on a Mortscript to also turn one of the LED's on and off when music is playing...

But it turns out that as long as WIFI is turned on, the blue LED on top of the device only comes on when the device is powered up, so I don't need to script it at all.

This LED will also be dissected and used as the gate for a MOSFET that will turn the amp on and off when the doorbell button is pushed.

I like Androids, but WM devices still have a lot of life left in them!

ironhead65
11th July 2011, 12:43 PM
Hello all,

I've been working on an Alarm Clock, using Mortscripts. So far, it works VERY well. As soon as I get something finished up, I will post it here.

Features:
-Up to 10 independent alarms
-DOW (Day of Week) selector
-Event time
-Starting system volume (not working yet) (Vibrate to max)
-Original volume is saved, so after you hit dismiss your phone's volume is set BACK to the volume it was set for prior to the alarm
-Vibrate additional to music
-MP3 to play
-Names
-Alarm Enable / Disable (if you go on vacation, you do not need to have the work alarm on)
-Some integration with Billboard v1.10
-Snooze

Features needed to be added:
-right now, only starts playing music at a LOW volume, then every 10 seconds volume increases by 5%...want to make this selectable between this and just play at ONE volume (system volume)
-Start volume
-One time alarm function (so far, only recurring)
-working on a program to read back things from the notification queue (to display on BillBoard)
-Variable time for Snooze
-Re-enable time...that is, if you know you are on vacation for a week, set the alarm disabled for 1 week. Then it will turn back on by itself (sometimes I forget to turn alarms back on the day before I must return to work).
-Maybe add a vibrate after so much time has past...so if you won't hit snooze or dismiss after say...2 minutes, the phone starts to vibrate

I've kind of run into a snag. I can't figure out how through tools or registry entries, you can tell if Windows Media Player Mobile is set for repeat or not. I found a few tools that let me control the volume and turn shuffle/repeat on / off, but how can I tell that it IS set on/off? I tried to do the "mouseclick" or "sendrightsoft" then navigate the menus...but those commands do not seem to function with Windows Media Player.

Also, I've been using this in it's v0.4 state for about 4 weeks. So far the only time it has not woken me up was when I set the alarm disable improperly. I've been enjoying getting up to soft music that gradually gets louder. Typically this will wake me before my wife, which gives me a lot of points!

Thanks for any ideas!

--Ironhead

Bumpity Bump?

RoryB
11th July 2011, 01:09 PM
Bumpity Bump?
I might be able to help with some parts.

For the re-enable time you could use a registry or inifile value to activate or de-activate the alarm operation. You could then set up a feature that changes that value and creates a notification queue item to change that value back at the end of the "no alarm" period.

Variable snooze could also be an inifile or registry value.

A lot of features that you want to have variable can be handled in inifile or registry values, but these would be variable for the entire group. Otherwise you would have to have more subsets in the inifile or registry.

ironhead65
11th July 2011, 01:11 PM
RoryB,

Thanks for the reply. I've got most of that figured out. The snag I've run into, is determining if Repeat is selected in Media Player. I tried using mouseclick commands, but they do not seem to have any affect on Media Player.

So, I was hoping someone knew some other way to get that information.

--Ironhead

RoryB
11th July 2011, 01:28 PM
I do not know, but will try to see if I can find MediaPlayer info in registry or somewhere else.

ironhead65
11th July 2011, 04:09 PM
If Mortplayer allows you to script-select repeat, maybe I just need to change over to that?

I was trying to use the built in WM stuff to make the Alarm Clock a bit more "universal".

--Ironhead

jwoegerbauer
12th July 2011, 07:04 PM
@RoryB,

Those are the default CE MediaPlayer settings in registry (taken from CAB-file):

HKLM\Software\Microsoft\WMDM\CurrentInUseVersion 3.0 REG_SZ
HKLM\Software\Microsoft\Windows Media Player 8\Background Unmap 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Audio\Volume 00001964 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Audio\Play Unsupported 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Audio\Background Quality 00000002 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Audio\Foreground Quality 00000002 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Audio\Support16 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Audio\Support32 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Audio\High Bitrate Dialog 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Audio\Play Unsupported Dialog 00000001 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Button Map 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Buttons\Down 00000028 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Buttons\Up 00000026 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Buttons\Action 0000000D REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Buttons\Left 00000025 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Buttons\Right 00000027 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Parameters\SkinDir \Program Files\Windows Media Player 7.1\ REG_SZ
HKLM\Software\Microsoft\Windows Media Player 8\Parameters\SkinFile Default.skn REG_SZ
HKLM\Software\Microsoft\Windows Media Player 8\Recent Playlists 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Proxy Address REG_SZ
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Connection Speed 00009C79 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Proxy Port 00000032 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Use Proxy 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\HTTP Support 00000001 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\TCP Support 00000001 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\UDP Port 0000C095 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\UDP Support 00000001 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Multicast 00000001 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Streaming Buffer 00000005 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Streaming Only 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Local Buffer 00000003 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Streaming\Local Only 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Version 8.0 REG_SZ
HKLM\Software\Microsoft\Windows Media Player 8\Video\Play Unsupported 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Video\Sound Quality 00000002 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Video\Full Screen Rotated 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Video\Full Screen 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Video\Fit Width 00000000 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Video\Maximum Width 000000F0 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Video\Maximum Height 00000140 REG_DWORD
HKLM\Software\Microsoft\Windows Media Player 8\Video\Color Depth 00000010 REG_DWORD
HKCR\.mp3 mp3file REG_SZ
HKCR\mp3file MPEG Layer 3 File REG_SZ
HKCR\mp3file\EditFlags 00010000 REG_DWORD
HKCR\mp3file\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\mp3file\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.wma wmafile REG_SZ
HKCR\wmafile Windows Media Audio File REG_SZ
HKCR\wmafile\EditFlags 00010000 REG_DWORD
HKCR\wmafile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\wmafile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.asf asffile REG_SZ
HKCR\asffile Windows Media File REG_SZ
HKCR\asffile\EditFlags 00010000 REG_DWORD
HKCR\asffile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\asffile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.wmv wmvfile REG_SZ
HKCR\wmvfile Windows Media Video File REG_SZ
HKCR\wmvfile\EditFlags 00010000 REG_DWORD
HKCR\wmvfile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\wmvfile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.wmp wmpfile REG_SZ
HKCR\wmpfile Windows Media File REG_SZ
HKCR\wmpfile\EditFlags 00010000 REG_DWORD
HKCR\wmpfile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\wmpfile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.asx asxfile REG_SZ
HKCR\asxfile Windows Media Shortcut REG_SZ
HKCR\asxfile\EditFlags 00010000 REG_DWORD
HKCR\asxfile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\asxfile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.wmx wmxfile REG_SZ
HKCR\wmxfile Windows Media Shortcut REG_SZ
HKCR\wmxfile\EditFlags 00010000 REG_DWORD
HKCR\wmxfile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\wmxfile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.wvx wvxfile REG_SZ
HKCR\wvxfile Windows Media Video Shortcut REG_SZ
HKCR\wvxfile\EditFlags 00010000 REG_DWORD
HKCR\wvxfile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\wvxfile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.wax waxfile REG_SZ
HKCR\waxfile Windows Media Audio Shortcut REG_SZ
HKCR\waxfile\EditFlags 00010000 REG_DWORD
HKCR\waxfile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\waxfile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\.wm wmfile REG_SZ
HKCR\wmfile Windows Media File REG_SZ
HKCR\wmfile\EditFlags 00010000 REG_DWORD
HKCR\wmfile\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\wmfile\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKLM\Software\Microsoft\Shell\URLProtocols\mms REG_SZ
HKLM\Software\Microsoft\Shell\URLProtocols\mmst REG_SZ
HKLM\Software\Microsoft\Shell\URLProtocols\mmsu REG_SZ
HKCR\mms URL:Windows Media Streaming Protocol REG_SZ
HKCR\mms\URL Protocol REG_SZ
HKCR\mms\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\mms\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\mmst URL:Windows Media Streaming Protocol REG_SZ
HKCR\mmst\URL Protocol REG_SZ
HKCR\mmst\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\mmst\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ
HKCR\mmsu URL:Windows Media Streaming Protocol REG_SZ
HKCR\mmsu\URL Protocol REG_SZ
HKCR\mmsu\DefaultIcon \Program Files\Windows Media Player 7.1\Player.exe, -2001 REG_SZ
HKCR\mmsu\Shell\Open\Command "\Program Files\Windows Media Player 7.1\player.exe" "%1" REG_SZ

RoryB
12th July 2011, 08:23 PM
I looked in my registry too. I do not have the same registry keys as you.

I do have some in HKLM and HKCU.

I noticed in HKCU\Software\Microsoft\MediaPlayer\Preferences value of Repeat = 1 DWord for repeat on and 0 for repeat off

Changing this value prior to opening WMP sets the mode to repeat or not.

ironhead65
12th July 2011, 09:56 PM
Rory! AWESOME!

That did it!

A few more items, and I think I'll be ready to post. Then the main thing is making an installer and waiting for people to break things, or suggest better methods of doing things (I made the functionality work well, but maybe humans would rather the menu layout, or choices be defined better, different wording, or different menu structure )

--Ironhead

okiookio
16th July 2011, 03:01 PM
Please tell me about that funstion:
string = ReadLine( <file/url> [,<codepage>] )
i want read the 3th line on a text file but how to use that function?
is that true ?

string = ReadLine("\storage card\mytext.txt",3)

please help me !!!

RoryB
16th July 2011, 05:02 PM
Please tell me about that funstion:

i want read the 3th line on a text file but how to use that function?
is that true ?

string = ReadLine("\storage card\mytext.txt",3)

please help me !!!
You have to readline three times to get the third line

Repeat(3)
string = ReadLine("\storage card\mytext.txt")
EndRepeat

Codepage is for different format of data like unicode

okiookio
17th July 2011, 01:07 PM
You have to readline three times to get the third line

Repeat(3)
string = ReadLine("\storage card\mytext.txt")
EndRepeat

Codepage is for different format of data like unicode

^^ thank bro and now please tell me how to use that function :
WriteLine( <file>,<line>[,<codepage>] ) ???

i want to insert a line ( eg : okio ) to the any line ( the 2nd line )

http://farm3.anhso.net/upload/20110717/19/o/anhso-191000_wls.jpg

RoryB
17th July 2011, 04:07 PM
Writeline only writes lines. You would have to readline 1 and then writeline it to an new file. Then writeline the line 2 you want and the readline the remaining lines one at a time and writeline them to the new file. After you are done you could move the new file to be the old file's name and overwrite.

Are you adding a line 2 or replacing the old line 2 with a new one?

Are the lines unique? If so, you could readfile and then replace the string of text and then writefile to update.

jwoegerbauer
17th July 2011, 04:33 PM
Why so complicated? This is how I'ld do it:

1) You read in the file

file="blahblah.ext"
in=ReadFile(file)

2) You create two arrays of file lines

in=Split(in,"^NL^")
out=Array()

3) You walk the lines read in, i.e. operate on them

idx=0
ForEach line In Array(in)
idx+=1
#Here you do with line what you will


#Ex. You insert after line #2 a new line #3
If(idx=3)
out[idx]="This is an inserted line"
#Advance
idx+=1
EndIf

#Store the line you worked with
out[idx]=line
Sleep 50
EndForEach

4) You write back the changed file contents

out=Join(out,"^NL^")
WriteFile(file,out,0)

ironhead65
18th July 2011, 10:19 PM
That only works for small files.

If the file is too large, his PPC/Phone might choke.

--Ironhead

ironhead65
19th July 2011, 01:14 PM
I will say, that code DOES work GREAT on a PC!! Thanks for the "easier" way to do string manipulation. I never thought to use an array and then Join at the end.

--Ironhead

ironhead65
19th July 2011, 04:38 PM
DOH! Join apparently limits you to 256 array items.

--Ironhead

jwoegerbauer
19th July 2011, 05:45 PM
You are right, it's the case with both the PC and the PNA version! Very surprisingly. I didn't know this before. Sorry for this. Severe bug in (latest) MortScript version! And, Mort has stopped development 2 years ago, hence we must live with this bug.

Knowing of this bug, as a workaround we could code a (very slow operating) function InsertLine() as listet next

Sub InsertLine(file,pos,insertion)
Local(in,line,idx,append)
in=ReadFile(file,FileSize(file,MB))
in=Split(in,"^NL^")
idx=0
ForEach line In Array(in)
idx+=1
append=((idx=1)?0:1)
If(idx=pos)
WriteFile(file,insertion&"^NL^",append)
Else
WriteFile(file,line&"^NL^",append)
EndIf
#yield, thus system has the chance to write
Sleep 250
EndForEach
EndSub

we call as following: @InsertLine("blahblah.txt",3,"This is an inserted line")

Only to complete things, a complementary function DeleteLine() could be coded as listet next

Sub DeleteLine(file,pos)
Local(in,line,idx,append)
in=ReadFile(file,FileSize(file,MB))
in=Split(in,"^NL^")
idx=0
ForEach line In Array(in)
idx+=1
append=((idx=1)?0:1)
If(idx<>pos)
WriteFile(file,line&"^NL^",append)
EndIf
#yield, thus system has the chance to write
Sleep 250
EndForEach
EndSub


we call as following: @DeleteLine("blahblah.txt",3)

beerpp
22nd July 2011, 12:24 PM
Hi!

Is there any way to have a script to edit multiple contact numbers of different contacts in my phone book?

Basically problem is : I have 2 phones (Both HTC Raphaels). My primary phone has all numbers and I sync both phones with my PC. My secondary phone's carrier doesnt allow "+" code dialling. E.g. - I cant dial +91XXXXXXXXXX. I have to dial 0XXXXXXXXXX. My primary phone's carrier allows me to dial both types of numbers. So what I would like to achieve is to churn out a script which will allow me to replace all "+91" with "0" for all contacts in my phone book on my secondary phone after I sync it with my PC.

Details - 1st device = AT&T Fuze, 2nd device = Sprint HTC Touch Pro. Windows Mobile 6.5 Pro (Customised ROMs).

I am studying MortScript documentation now but havent yet hit a solution.

Warning - I am a bit of a noob with scripting.

Thanks!

michoob
22nd July 2011, 02:35 PM
@beerpp: first, I don't think you can directly edit contacts with MortScript. Maybe by using command lines of some apps...
Anyway, why would you use a MortScript to do a thing that you could just configure on Windows Mobile?
It seems to me that the following thread (http://forum.xda-developers.com/showthread.php?t=359674) might answer to your primary dialing question. From that thread, it would be enough just to set/create the following registry keys and values:
HKLM\Software\OEM\PhoneSetting
HiddenPlusCodeDialingPage=0

HKLM\Software\OEM\PhoneSetting\PlusCodeDialing
PlusCodeEnable=1
PlusCodeNumber=011
ResetNumber=011

RoryB
22nd July 2011, 11:17 PM
I do not think MortScript edits database files. Can you extract data to a txt format file? Then maybe edit and import to database?

beerpp
23rd July 2011, 03:45 PM
Thanks michoob and RoryB!!! The thread (http://forum.xda-developers.com/showthread.php?t=359674) helped and I was able to coonfigure phone settings to replace the "+" with "00". So my problem is solved. Thanks!

But I am still interested in editing multiple numbers using an automated script/program. I have a roundabout method as of now.

Use Mortscript to achieve following:
1. Call a program to export contacts to an excel file.
2. Open that excel file and replace all "+91" with "0".
3. Call a program to restore contacts from the excel file.

This script can be made to run after every sync or every time USB is disconnected.

michoob
25th July 2011, 08:13 AM
@beerpp: you will not be able to edit an xls file with MortScript, but why not a csv file ;).
You could use PIMbackup (http://forum.xda-developers.com/showthread.php?t=299705) export your contacts in a csv file, then edit that file with MortScript and import this file back with PIMbackup.
But I have never used the command lines of PIMbackup, so I do not know how far this can be automated with MortScript... you to test ;)

jwoegerbauer
25th July 2011, 11:49 AM
@beerpp,

this article might be useful, if you try dotFred's PIMBackup, @michoob linked to: http://manish.wordpress.com/2008/11/14/importing-contacts-to-windows-mobile-without-ms-outlook/

raving_nanza
29th July 2011, 06:33 AM
editing script
mscrread = readfile("\location\p1.mscr")
mscrread = Replace(mscrread, "xxx", "yyy")
WriteFile("\location\p1.mscr", mscrread )
CloseFile("\location\p1.mscr" )

as you can see this reads p1 script and searches for xxx, then replaces it with yyy and saves.

how do i copy multiple lines of text as "yyy"

eg, so i can basicly add more commands into the p1 script? :cool:


cheers dudes :)

CLHatch
29th July 2011, 08:09 AM
editing script
mscrread = readfile("\location\p1.mscr")
mscrread = Replace(mscrread, "xxx", "yyy")
WriteFile("\location\p1.mscr", mscrread )
CloseFile("\location\p1.mscr" )

as you can see this reads p1 script and searches for xxx, then replaces it with yyy and saves.

how do i copy multiple lines of text as "yyy"

eg, so i can basicly add more commands into the p1 script? :cool:


cheers dudes :)

By using the following character combinations in the string:
7.3 Fixed strings
Fixed strings must be surrounded by quotes (").
To use quotes inside a quoted string, you have to double them, e.g..
Message( "He said: ""This is a test""" )
-> Will show „He said: "This is a test"”.
The following combinations will be replaced with special characters:
^CR^ -> Carriage Return
^LF^ -> Line Feed
^NL^ -> Windows-/DOS line bread in files (New line, consists of CR+LF)
^TAB^ -> Tabulator
In Windows, a new line in text files usually is the combination of carriage return and line feed
(^CR^^LF^ = ^NL^). But sometimes there are also files in Unix style, which use only ^LF^.

So, just use ^NL^ inside the string for a new line (or ^LF^ or ^CR^, depending on what kind of new line you need), such as:
mscrread = Replace(mscrread, "xxx", "line1^NL^line2^NL^line3")
To make it easier to read for multiple lines of text, you could also do something like this
mscrread = Replace(mscrread, "xxx", "line1^NL^" & \
"line2^NL^" & \
"line3"\
)
or this
mscrread = Replace(mscrread, "xxx", "\
line1^NL^\
line2^NL^\
line3\
")


Seems you could also use "Join" with an array of lines to add...
aryScript=Array( \
"line1", \
"line2", \
"line3" \
)
strScript=Join(aryScript, "^NL^")
mscrread = Replace(mscrread, "xxx", strScript)


9.5.6 Join multiple array elements to string (Join)
string = Join( array [, concatenation ] )
Join is the counterpart to “Split”. It concatenates all elements with numerical index starting from 1
to the first unassigned index to a single string. If concatenation is given, this string will be inserted
between the single elements.
Examples:
str = Join( Array( "a", "b", "c" ), "|" )
-> str = "a|b|c"
arr[1] = "This"
arr[2] = "is"
arr["3"] = "a"
arr[04] = "test"
arr["test"] = "of"
arr[6] = "Join"
str = Join( arr )
-> str = "Thisisatest" ("3" is converted to numerical index, "test" is alphanumerical, 5 is missing, so
6 isn't regarded)

I've been away from MortScript for a while, but the code looks right. :D

raving_nanza
29th July 2011, 03:21 PM
cheers dude, ill look into it asap :D

jwoegerbauer
29th July 2011, 04:40 PM
editing script
mscrread = readfile("\location\p1.mscr")
mscrread = Replace(mscrread, "xxx", "yyy")
WriteFile("\location\p1.mscr", mscrread )
CloseFile("\location\p1.mscr" )


1) CloseFile() doesn't exists in MortScript. Note that each ReadFile() / WriteFile() operation implicitely opens/closes the file you work with.

2) Note that if you work with large files a. ReadFile() allocates "original file size" bytes in RAM - 1st allocation, b. Replace() allocates "new file size" bytes in RAM - 2nd allocation, hence you must (for a short time) have "original file size" + "new file size" bytes RAM available, which might not always be the case. It's probably cleaner and less RAM-wasting to have in the original MSCR-file a line such as CallScript("xyz.mscr") and, if needed, create with WriteFile() on the fly a new xyz.MSCR-file, before running the original .MSCR-file.

3) ReadFile() should, to be on the safe side, be used as following, IMO:

in=""&ReadFile(infile,FileSize(infile,BYTES))
If(Length(in))
#do process
Else
#do error
EndIf

RoryB
29th July 2011, 05:19 PM
3) ReadFile() should, to be on the safe side, be used as following, IMO:

in=""&ReadFile(infile,FileSize(infile,BYTES))
If(Length(in))
#do process
Else
#do error
EndIfAre you saying we should always set "length" to the actual file length instead of using the default 1MB? In other words if the file is less than 1MB and you use the default, does MortScript allocate a full 1MB anyway?

BTW, I like your test to avoid trying to do process on an empty file.

And I assume the ""& is to avoid NUL value and get 0 value in length(in)

CLHatch
29th July 2011, 10:42 PM
1) CloseFile() doesn't exists in MortScript. Note that each ReadFile() / WriteFile() operation implicitely opens/closes the file you work with.

2) Note that if you work with large files a. ReadFile() allocates "original file size" bytes in RAM - 1st allocation, b. Replace() allocates "new file size" bytes in RAM - 2nd allocation, hence you must (for a short time) have "original file size" + "new file size" bytes RAM available, which might not always be the case. It's probably cleaner and less RAM-wasting to have in the original MSCR-file a line such as CallScript("xyz.mscr") and, if needed, create with WriteFile() on the fly a new xyz.MSCR-file, before running the original .MSCR-file.

3) ReadFile() should, to be on the safe side, be used as following, IMO:

in=""&ReadFile(infile,FileSize(infile,BYTES))
If(Length(in))
#do process
Else
#do error
EndIf

Actually, CloseFile does exist in MortScript. Here's the excerpt from the manual:
9.13 Reading and writing text files
9.13.1 Reading a text file (ReadFile, ReadLine)
string = ReadFile( file name [, length [, codepage ] ] )
string = ReadLine( file name [, codepage ] )
ReadFile reads the entire contents of a text file into the variable. The file size is limited to length,
1 MB or the available memory (whichever is the least). If length is 0, the default maximum (1 MB)
is used.
ReadLine reads a single line of the given text file. The next time ReadLine is invoked, it returns the
next line, etc. If there are no more lines in the file, it returns an empty value (see 9.2.4 Check if
variable is assigned (IsEmpty)). Opposed to ReadFile, ReadLine only works with “real” files, not
with serial ports (see 9.13.6 Access serial ports (SetComInfo)) or Internet access.
Possible values for the codepage are either the codepage numbers (if you know them) like 1252
(Western Europe), 437 (American DOS), ... or any of those strings:
● "latin1" (Western Europe)
● "jis" (Japanese)
● "wansung" (Korean)
● "johab" (Korean)
● "chinesesimp" (Chinese simplified)
● "chinesetrad" (Chinese traditional)
● "hebrew"
● "arabic"
● "greek"
● "turkish"
● "baltic"
● "latin2" (mostly Eastern Europe)
● "cyrillic"
● "thai"
● "utf8" (special encoding only for non-ASCII characters)
● "unicode" (2 bytes for each character, to be more precise UTF-16 little endian)
● "utf8-prefix" (like "utf8", but file starts with the hex values EF BB BF, which is an indicator
for some editors/programs)
● "unicode-prefix" (similar to "utf8-prefix", but with FF FE prefix and unicode)
Default is the system's default codepage, which depends on your Windows localization. UTF8 or
Unicode encoded files are also recognized, if they start with the corresponding prefixes (see “-
prefix” encodings above).
You can parse the file e.g. with ForEach line in split ( contents, "^LF^", TRUE )
See also the ForEach possibilities for INI files and ReadINI/WriteINI!
Example for ReadLine:
StatusType( ST_LIST, TRUE, FALSE )
StatusHistorySize( 500 )
line = ReadLine( "test.txt" )
While( NOT IsEmpty( line ) )
StatusMessage( line )
line = ReadLine( "test.txt" )
EndWhile

9.13.2 Writing to a text file (WriteFile, WriteLine)
WriteFile( file name, contents [, append? [, codepage ] ] )
WriteLine( file name, contents [, append? [, codepage ] ] )
Writes the contents to the file.
For WriteFile, if append? is FALSE or the parameter is omitted, an existing file will be overwritten,
otherwise the given contents is appended at the end of the existing data.
WriteLine always appends at the end, and also adds a new line. The file remains opened until
CloseFile or the end of the script. Due to that, WriteLine is faster than WriteFile with append
option, but there might be problems when the file is accessed otherwise (other programs, trying to
delete it, …).
For possible values for codepage, please see ReadFile above. The “-prefix” variations only are
applied if append? is FALSE!

9.13.3 Closing a file (CloseFile)
CloseFile( file name )
Closes a file which was opened with ReadLine or WriteLine. ReadLine automatically closes a file
after the last line. All opened files are closed after the script ends. Nonetheless, you should close
files whenever you don't need to access them anymore to avoid access problems.

RoryB
29th July 2011, 11:14 PM
Closefile would not be required for writefile since it closes the file behind itself.

Only readline and writeline need a closefile if you plan to call the file before the script ends. The file closes whenever the script ends.

So if you read a few lines from a file and then wanted to do something else with it you need to do closefile or if you write a line to a file you should closefile before trying to do something else with it.

CLHatch
29th July 2011, 11:17 PM
Closefile would not be required for writefile since it closes the file behind itself.

Only readline and writeline need a closefile if you plan to call the file before the script ends. The file closes whenever the script ends.

So if you read a few lines from a file and then wanted to do something else with it you need to do closefile or if you write a line to a file you should closefile before trying to do something else with it.

True, CloseFile is not needed for ReadFile or WriteFile... was merely pointing out that the command did actually exist. :)

jwoegerbauer
30th July 2011, 07:31 AM
True, CloseFile is not needed for ReadFile or WriteFile... was merely pointing out that the command did actually exist. :)
FYI: That's content of german version (the basic version - at least I thought so, because MortScript was developed by Mirko Schenk ("Mort"), a german citizen as also I'm one) of MortScript-Manual (4.3.b.15), a CloseFile() isn't mentioned there:

9.13 Lesen und Schreiben von Dateien

9.13.1 Lesen einer Datei (ReadFile, ReadLine)
Zeichen = ReadFile( Dateiname [, Länge [, Kodierung ] ] )
Zeichen = ReadLine( Dateiname [, Kodierung ] )

9.13.2 Schreiben in eine Datei (WriteFile)
WriteFile( Dateiname, Inhalt [, Anhängen? [, Kodierung ] ] )

9.13.3 Lesen eines Werts aus einer INI-Datei (IniRead)
Zeichen = IniRead( Dateiname, Abschnitt, Schlüssel [, Kodierung ] )

9.13.4 Schreiben eines Werts in eine INI-Datei (IniWrite)
x = IniWrite( Dateiname, Abschnitt, Schlüssel, Wert[, Kodierung ] )



Hence the wrong statement by me. Sorry for this. In between I ran a script as following

#ReadLineTest.mscr
ErrorLevel("warn")
Local(in,line)
in=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")
#Start reading
line=""&ReadLine(in)
While(Length(line))
#Process line

#Advance to next line, if any
line=""&ReadLine(in)
EndWhile
#Clear file pointer
CloseFile(in)
#Start reading again
line=""&ReadLine(in)


and noticed, that if you decide to read the file more than once, you indeed have to add command CloseFile() before reading again, otherwisely the file pointer wouldn't be re-set.

BTW: If you run a script as following

#WriteLineTest.mscr
ErrorLevel("warn")
Local(in,out,line)
in=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")
out=SystemPath("ScriptPath")\SystemPath("ScriptName")&"2"&SystemPath("ScriptExt")
line=""&ReadLine(in)
While(Length(line))
WriteLine(out,line)
#yield
Sleep 500
line=""&ReadLine(in)
EndWhile

only 1st line of "in" is written (duplicated) to "out", then you get error message WriteLine: writelinetest2.mscr could not be opened, though "out" was created. Any ideas why this?

RoryB
30th July 2011, 02:40 PM
Not sure why you got the error, but if you add closefile for out file just before the endwhile maybe that will work.

raving_nanza
30th July 2011, 05:05 PM
mscrread = Replace(mscrread, "xxx", "\
line1^NL^\
line2^NL^\
line3\
")

Hi dudes

this is exactly what i need.. btw thanks its working how i need it to :)

fyi i will be opening more than one .mscr file with this script so i can edit multiple scripts with just one script.. so i think the "closefile" will definatly be needed ;)


Rn

CLHatch
4th August 2011, 06:42 PM
mscrread = Replace(mscrread, "xxx", "\
line1^NL^\
line2^NL^\
line3\
")

Hi dudes

this is exactly what i need.. btw thanks its working how i need it to :)

fyi i will be opening more than one .mscr file with this script so i can edit multiple scripts with just one script.. so i think the "closefile" will definatly be needed ;)


Rn

According the the manual, CloseFile is only needed for ReadLine and WriteLine, so it shouldn't be needed in your script, using ReadFile and WriteFile. But it certainly doesn't hurt to use CloseFile anyways, in case the manual is wrong. :D

RoryB
4th August 2011, 07:04 PM
It must be WriteFile and WriteLine week. We have two different people doing stuff with files. Please be careful to read the responses to be sure one of us is answering your specific question.

I agree that using CloseFile should not hurt anything with WriteFile since you are done with the file as soon as WriteFile is done.

@CLHatch, what I like about computers is they help you really foul things up much faster and more deeply.

CLHatch
4th August 2011, 07:08 PM
It must be WriteFile and WriteLine week. We have two different people doing stuff with files. Please be careful to read the responses to be sure one of us is answering your specific question.

I agree that using CloseFile should not hurt anything with WriteFile since you are done with the file as soon as WriteFile is done.

@CLHatch, what I like about computers is they help you really foul things up much faster and more deeply.
Yep... With today's technology, we can make more mistakes faster than ever before!

CLHatch
4th August 2011, 07:47 PM
FYI: That's content of german version (the basic version - at least I thought so, because MortScript was developed by Mirko Schenk ("Mort"), a german citizen as also I'm one) of MortScript-Manual (4.3.b.15), a CloseFile() isn't mentioned there:

9.13 Lesen und Schreiben von Dateien

9.13.1 Lesen einer Datei (ReadFile, ReadLine)
Zeichen = ReadFile( Dateiname [, Länge [, Kodierung ] ] )
Zeichen = ReadLine( Dateiname [, Kodierung ] )

9.13.2 Schreiben in eine Datei (WriteFile)
WriteFile( Dateiname, Inhalt [, Anhängen? [, Kodierung ] ] )

9.13.3 Lesen eines Werts aus einer INI-Datei (IniRead)
Zeichen = IniRead( Dateiname, Abschnitt, Schlüssel [, Kodierung ] )

9.13.4 Schreiben eines Werts in eine INI-Datei (IniWrite)
x = IniWrite( Dateiname, Abschnitt, Schlüssel, Wert[, Kodierung ] )



Hence the wrong statement by me. Sorry for this. In between I ran a script as following

#ReadLineTest.mscr
ErrorLevel("warn")
Local(in,line)
in=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")
#Start reading
line=""&ReadLine(in)
While(Length(line))
#Process line

#Advance to next line, if any
line=""&ReadLine(in)
EndWhile
#Clear file pointer
CloseFile(in)
#Start reading again
line=""&ReadLine(in)


and noticed, that if you decide to read the file more than once, you indeed have to add command CloseFile() before reading again, otherwisely the file pointer wouldn't be re-set.

BTW: If you run a script as following

#WriteLineTest.mscr
ErrorLevel("warn")
Local(in,out,line)
in=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")
out=SystemPath("ScriptPath")\SystemPath("ScriptName")&"2"&SystemPath("ScriptExt")
line=""&ReadLine(in)
While(Length(line))
WriteLine(out,line)
#yield
Sleep 500
line=""&ReadLine(in)
EndWhile

only 1st line of "in" is written (duplicated) to "out", then you get error message WriteLine: writelinetest2.mscr could not be opened, though "out" was created. Any ideas why this?
Not really sure why you are getting an error, but I do know you need to modify that WriteLine to tell it to APPEND to the file, and it is best to close both files yourself when done with them:
#WriteLineTest.mscr
ErrorLevel("warn")
Local(in,out,line)
in=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")
out=SystemPath("ScriptPath")\SystemPath("ScriptName")&"2"&SystemPath("ScriptExt")
line=""&ReadLine(in)
While(Length(line))
WriteLine(out,line,TRUE)
#yield
Sleep 500
line=""&ReadLine(in)
EndWhile
CloseFile(in)
CloseFile(out)

Edit:
Looking at it closer, I see why the error now. You were not using the "Append" option (that ,TRUE in the WriteLine), so it was trying to create a new file each time it was called. This worked for the first call, but since there was no CloseFile before the second call to WriteFile, it couldn't create the file, because it was still open. Simply adding that ,TRUE should fix it for you, causing the text to be appended to the end of the file instead of attempting to overwrite the file.

raving_nanza
4th August 2011, 08:15 PM
CloseFile should not hurt anything with WriteFile since you are done with the file as soon as WriteFile is done.

so there is no need to edit my 100+ scripts to delete the CloseFile command :D

RoryB
4th August 2011, 08:38 PM
so there is no need to edit my 100+ scripts to delete the CloseFile command :D

I do not think so. My thinking is if the file is already closed and you tell it to close, what can happen?

Playing with it seems that it does not matter even if the file does not exist. I mean I do not get an error if I use CloseFile and the file does not exist.

raving_nanza
6th August 2011, 10:50 PM
if i had a registry string that had a sum of money of eg, = £XXX amount.


a) how would i increase/decrease the sum of money by £YYY amount?
eg, if £XXX was £100 and i wanted to increase it by £100 = £200
eg, if £XXX was £100 and i wanted to decrease it by £100 = £000


b) if the sum of money £XXX would fall below £000 when decreasing the amount, how would i make it error or cancel?
eg, if £XXX was £100 and i wanted to decrease it by £200 = ERROR


c) how would i prevent someone from exceding a certain amount when increaseing, eg put a cap on it for £ZZZ amount?
eg, if £ZZZ was £100 and i wanted to increase £XXX by £1000 = ERROR



thanks


EDIT: this is basicly what im hoping for, if i can get this to work, my "secret project" will be fluid in motion :D


RegWriteString("HKCU", "Software\RVN\", "LIMIT", £ZZZ )
#
£££ = Input("ENTER DESIRED £££:")
IF(£££ eq "")
EXIT
#
Else
RegWriteString("HKCU", "Software\RVN\", "MONEY £XXX", £££ )
ENDIF
#
RegReadString("HKCU", "Software\RVN\", "MONEY £XXX", £££ )
#
IF £££ = MONEY EXCEEDS £ZZZ LIMIT
Run ("\windows\error.xxx")
ENDIF
#
IF £££ = MONEY EXCEEDS -£000 LIMIT
Run ("\windows\error.xxx")
ENDIF
#
IF £££ = MONEY IS OK
Run ("\windows\ok.xxx")
ENDIF

RoryB
7th August 2011, 04:13 AM
Try this. I did not have a chance to test myself.
RegWriteString("HKCU", "Software\RVN\", "LIMIT", £ZZZ )
#
£££ = Input("ENTER DESIRED £££:")
IF(£££ eq "")
EXIT
#
Else
RegWriteString("HKCU", "Software\RVN\", "MONEY £XXX", £££ )
ENDIF
#
IF (£££ > £ZZZ)
Run ("\windows\error.xxx")
ElseIF( (-1 * £££) > £000)
Run ("\windows\error.xxx")
Else
Run ("\windows\ok.xxx")
ENDIF

RegWriteString("HKCU", "Software\RVN\", "LIMIT", £ZZZ )
#
£££ = Input("ENTER DESIRED £££:")
IF(£££ eq "")
EXIT
#
Else
RegWriteString("HKCU", "Software\RVN\", "MONEY £XXX", £££ )
ENDIF
#
IF (£££ > £ZZZ or (-1 * £££) > £000)
Run ("\windows\error.xxx")
Else
Run ("\windows\ok.xxx")
ENDIF

raving_nanza
7th August 2011, 05:17 AM
cheers dude :D

been waiting for a post from someone all morning :rolleyes:

perfect timing though dude, ive just finished writing my sound files :)

thanks


EDIT:

how would i ADD the £XXX amount of money with £YYY amount which will = £AAA?

eg, would it be something like this?

IF (£££ < £ZZZ)
#less than
(£XXX + £YYY = £AAA)
#adds them both up
RegWriteString("HKCU", "Software\RVN\", "TOTAL", £AAA )
#writes a total in registry
ENDIF


*ive now got:
(C) working perfectly :D

btw this is a huge part of the project so sorry if its hard to understand :rolleyes:
(i can hardly understand it myself :D haha oj)

RoryB
7th August 2011, 12:41 PM
IF (£££ < £ZZZ) #less than
£AAA = £XXX + £YYY
#adds them both up
RegWriteString("HKCU", "Software\RVN\", "TOTAL", £AAA )
#writes a total in registry
ENDIF

raving_nanza
7th August 2011, 01:45 PM
your a F-ing star dude :D

thanks

jwoegerbauer
13th August 2011, 06:21 PM
Not really sure why you are getting an error, but I do know you need to modify that WriteLine to tell it to APPEND to the file, and it is best to close both files yourself when done with them:
#WriteLineTest.mscr
ErrorLevel("warn")
Local(in,out,line)
in=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")
out=SystemPath("ScriptPath")\SystemPath("ScriptName")&"2"&SystemPath("ScriptExt")
line=""&ReadLine(in)
While(Length(line))
WriteLine(out,line,TRUE)
#yield
Sleep 500
line=""&ReadLine(in)
EndWhile
CloseFile(in)
CloseFile(out)

Edit:
Looking at it closer, I see why the error now. You were not using the "Append" option (that ,TRUE in the WriteLine), so it was trying to create a new file each time it was called. This worked for the first call, but since there was no CloseFile before the second call to WriteFile, it couldn't create the file, because it was still open. Simply adding that ,TRUE should fix it for you, causing the text to be appended to the end of the file instead of attempting to overwrite the file.

Sorry for delay, must confirm you got it! Thx.

CLHatch
14th August 2011, 04:28 PM
Not really sure why you are getting an error, but I do know you need to modify that WriteLine to tell it to APPEND to the file, and it is best to close both files yourself when done with them:
#WriteLineTest.mscr
ErrorLevel("warn")
Local(in,out,line)
in=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")
out=SystemPath("ScriptPath")\SystemPath("ScriptName")&"2"&SystemPath("ScriptExt")
line=""&ReadLine(in)
While(Length(line))
WriteLine(out,line,TRUE)
#yield
Sleep 500
line=""&ReadLine(in)
EndWhile
CloseFile(in)
CloseFile(out)

Edit:
Looking at it closer, I see why the error now. You were not using the "Append" option (that ,TRUE in the WriteLine), so it was trying to create a new file each time it was called. This worked for the first call, but since there was no CloseFile before the second call to WriteFile, it couldn't create the file, because it was still open. Simply adding that ,TRUE should fix it for you, causing the text to be appended to the end of the file instead of attempting to overwrite the file.
Sorry for delay, must confirm you got it! Thx.
I actually just noticed a couple of slight errors in logic, both in the original code and mine. First, for the original error... if I'm not mistaken, the code would stop on the first blank line, because the length of a blank line is 0 (the line feed is not included in the returned string). To fix that, you would use the code similar to the example in the manual, using IsEmpty (ReadLine returns an empty value at the end of file... note that "" is NOT an empty value). Second, now that we are using the Append flag, if the output file already exists, it will be appended to it instead of overwritten, and that file will keep getting larger each time the code is run; we need to be sure the file isn't there first. You can do that by either deleting the file, or by doing by the first WriteLine to it without the Append flag. Here's the new code, first error fixes in red, second error fixes in blue:
#WriteLineTest.mscr
ErrorLevel("warn")
Local(in,out,line)
in=SystemPath("ScriptPath")\SystemPath("ScriptName")&SystemPath("ScriptExt")
out=SystemPath("ScriptPath")\SystemPath("ScriptName")&"2"&SystemPath("ScriptExt")
If (FileExists(out))
Delete(out)
EndIf
line=ReadLine(in)
While(NOT IsEmpty(line))
WriteLine(out,line,TRUE)
#yield
Sleep 500
line=ReadLine(in)
EndWhile
CloseFile(in)
CloseFile(out)

lesscro
19th August 2011, 01:28 PM
@ RoryB...
Hello,

i have a problem using your wx_updater script...

it does nothing for me :

If (Solution( "RoRyB" ) = 1 )
Message ("Please help me")



i have 3 script to perfom action like your procedure.

Configuration in INI file : weather_autoupdater_config.mscr

# LeSScro Weather
# AutoUpdater
# based on ROryB ScriptProcExists
# weather updater for Gen.Y_Manila_R1_5-CAB.
#---------------------------------


mort = SystemPath("ScriptExe") & "\" & "MortScript.exe"
script = """" & SystemPath("ScriptPath") & "\" & "weather_autopdate.mscr" & """"
If( Question( "Do you want to stop weather updater?^NL^^NL^No to change settings.", "aCute weather updater", "YESNO" ))
RemoveNotifications(mort, script)
message( "Weather updater stopped." )
Else
inifile = SystemPath("ScriptPath") & "\" & "autoupdater.ini"
If( FileExists( inifile ))
# Got rid of the individual iniread lines with this foreach group
ForEach xkey, xvalue in iniKeys( inifile, "Settings" )
[xkey]=xvalue
# The [] around xkey tells the script to define a variable with the name equal to the value of xkey
EndForEach
Delete( inifile )
Else
delayHours = 2
RetryHours = 0.25
Activ8 = 6
Dactiv8 = 22
RapidHours = 0.5
Rapid1 = 6
Rapid2 = 9
Rapid3 = 17
Rapid4 = 21
SigStrg = 45
EndIf

delayHours = Input ( "Enter delay hours between each update:", "aCute weather updater", FALSE, FALSE, delayHours )
RetryHours = Input ( "Enter retry hours between each fail to start:", "aCute weather updater", FALSE, FALSE, RetryHours )
Activ8 = Input ( "Enter activation time 24 hr clock:", "aCute weather updater", FALSE, FALSE, Activ8 )
Dactiv8 = Input ( "Enter de-activation time 24 hr clock:", "aCute weather updater", FALSE, FALSE, Dactiv8 )
RapidHours = Input ( "Enter delay hours between each rapid update:", "aCute weather updater", FALSE, FALSE, RapidHours )
Rapid1 = Input ( "Rapid update morning start time 24 hr clock:", "aCute weather updater", FALSE, FALSE, Rapid1 )
Rapid2 = Input ( "Rapid update morning stop time 24 hr clock:", "aCute weather updater", FALSE, FALSE, Rapid2 )
Rapid3 = Input ( "Rapid update evening start time 24 hr clock:", "aCute weather updater", FALSE, FALSE, Rapid3 )
Rapid4 = Input ( "Rapid update evening stop time 24 hr clock:", "aCute weather updater", FALSE, FALSE, Rapid4 )
SigStrg = Input ( "Minimum signal strength to try to update:", "aCute weather updater", FALSE, FALSE, SigStrg )

writeFile( inifile, "[Settings]", TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "delayHours=" & delayHours, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "RetryHours=" & RetryHours, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "Activ8=" & Activ8, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "Dactiv8=" & Dactiv8, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "RapidHours=" & RapidHours, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "Rapid1=" & Rapid1, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "Rapid2=" & Rapid2, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "Rapid3=" & Rapid3, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "Rapid4=" & Rapid4, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "SigStrg=" & SigStrg, TRUE )
writeFile( inifile, "^NL^", TRUE )

RegWriteString ("HKCU", "LeSScro\weather", "AutoUpdater", delayHours)

Run( mort, script )
message( "Settings changed and weather updater started." )
EndIf

then i have script to perfom RunAt : weather_autoupdater.mscr
# LeSScro Weather
# AutoUpdater
# based on ROryB ScriptProcExists
# weather updater for Gen.Y_Manila_R1_5-CAB.
#---------------------------------

lastupdate = FormatTime( "{W}" & "" & "H:i:s")
inifile = SystemPath("ScriptPath") & "\" & "autoupdater.ini"
# >!--- Got rid of the individual iniread lines with this foreach group
ForEach xkey, xvalue in iniKeys( inifile, "Settings" )
[xkey]=xvalue
# >!--- The [] around xkey tells the script to define a variable with the name equal to the value of xkey
EndForEach
# Quietly ignore all errors
ErrorLevel("off")
Now = TimeStamp()
Tomorrow = Now+(24*60*60)
# check for accelerated weather check time period
# set up for next notification
If( (Rapid1 <= FormatTime("H", Now) AND FormatTime("H", Now) <= Rapid2 )) OR (Rapid3 <= FormatTime("H", Now) AND FormatTime("H", Now) <= Rapid4 ))
utime = Now + (RapidHours*60)*60
Else
utime = Now + (delayHours*60)*60
EndIf
Call( "NewNotif", utime )
# Start Time Window
If( Activ8 <= FormatTime("H", Now) AND FormatTime("H", Now) < Dactiv8 )
# Check signal strength
If( RegRead( HKLM, "System\State\Phone", "Signal Strength Raw" ) >= SigStrg )
ToggleDisplay(TRUE)
# Only run main task if Wisbar is active
If (ProcExists( "DesktopApp.exe" ))
CallScript( "weather_update.mscr" )
Else
utime = Now + (RetryHours*60)*60
Call( "NewNotif", utime )
EndIf
EndIf

Else
# >!--- if time is outside window of activation reset to start 1/2 hour after activation hour set in Activ8
If( Dactiv8 <= formatTime("H", Now) )
utime = MakeTimeStamp( FormatTime("Y", Tomorrow ), FormatTime("m", Tomorrow ), FormatTime("d", Tomorrow ), Activ8, 30 )
ElseIf( FormatTime("H", Now) < Activ8 )
utime = MakeTimeStamp( FormatTime("Y", Now), FormatTime("m", Now), FormatTime("d", Now), Activ8, 30 )
EndIf
Call( "NewNotif", utime )
EndIf

# >!--- Sub NewNotify
Sub NewNotif ( utime )
mort = SystemPath("ScriptExe") & "\" & "MortScript.exe"
script = """" & SystemPath("ScriptPath") & "\" & SystemPath("ScriptName") & SystemPath("ScriptExt") & """"
# kill any lingering notification
RemoveNotifications(mort, script)
# set notification to run at next time
RunAt( utime, mort, script)
Message ("weather update : " &lastupdate& "", "AutoUpdater aCUte")

EndSub

and scritp used to perform update, separate because i can use weather force UPDATE : weather_update.mscr
# LeSScro Weather
# based on JML tools
# http://forum.xda-developers.com/showthread.php?t=601777
# all credits to JMHL
#---------------------------------

# !>--- Definition
instPath = SystemPath( "ScriptPath" )
code = RegRead ("HKCU", "LeSScro\weather", "code")
myConnect = RegRead ("HKCU", "LeSScro\connect", "Connexion")
lastupdate = FormatTime( "{W}" & "" & "H:i:s")

# !>--- weather source
source = RegRead ("HKCU", "LeSScro\weather", "source")

# !>--- weather icon number
current = RegRead ("HKCU", "Software\JML\Meteo\current", "icon")
day1 = RegRead ("HKCU", "Software\JML\Meteo\day1", "icon")
day2 = RegRead ("HKCU", "Software\JML\Meteo\day2", "icon")
day3 = RegRead ("HKCU", "Software\JML\Meteo\day3", "icon")
day4 = RegRead ("HKCU", "Software\JML\Meteo\day4", "icon")

# !>--- weather icon directory
accu = "\LeSScro aCute\IMG\home\accu"
accublack = "\LeSScro aCute\IMG\home\accublack"
google = "\LeSScro aCute\IMG\home\google"
googleblack = "\LeSScro aCute\IMG\home\googleblack"
icon = "\LeSScro aCute\IMG\home"

If (InternetConnected( "http://www.bing.com" ) = 1 )
Call ("updater")
Else
Call ("connector")
EndIf

# !>--- Connector using user parameter
Sub connector
Connect (MyConnect)
Call ("updater")
EndSub

Sub Updater
# !>--- Code selector
If (source eq "accu")
RunWait(instPath & "\JMLMeteo.exe", "-accu:" & "" & code & "")
Copy( accu \ current, icon \ "current.png", TRUE )
Copy( accu \ day1, icon \ "day1.png", TRUE )
Copy( accu \ day2, icon \ "day2.png", TRUE )
Copy( accu \ day3, icon \ "day3.png", TRUE )
Copy( accu \ day4, icon \ "day4.png", TRUE )
Copy( accublack \ current, icon \ "currentB.png", TRUE )
RegWriteString ("HKCU", "LeSScro\weather","lastupdate", lastupdate)
PlaySound ( SystemPath( "ScriptPath" ) \ "success.wav")
ElseIf (source eq "google")
RunWait(instPath & "\JMLMeteo.exe", "-google:" & "" & code & "")
Copy( google \ current, icon \ "current.png", TRUE )
Copy( google \ day1, icon \ "day1.png", TRUE )
Copy( google \ day2, icon \ "day2.png", TRUE )
Copy( google \ day3, icon \ "day3.png", TRUE )
Copy( google \ day4, icon \ "day4.png", TRUE )
Copy( googleblack \ current, icon \ "currentB.png", TRUE )
RegWriteString ("HKCU", "LeSScro\weather","lastupdate", lastupdate)
PlaySound ( SystemPath( "ScriptPath" )\ "success.wav")
Else
RegWriteString ("HKCU", "LeSScro\weather","lastupdate", "update fail")
PlaySound ( SystemPath( "ScriptPath" )\ "fail.wav")
EndIf

CloseConnection

Exit
EndSub

RoryB
19th August 2011, 05:30 PM
1) Does the ini updater work? It looks like it should.

2) Does the updater give you the message and add an item to the notification queue? It looks like it should.

3) This one is a little harder for me to follow, but I suspect it. You can add messages to the script to track its progress.

I do things like message("HERE") or message("Source is: " source) and so on.

Does the data in the registry get updated, but not changed on the screen?

lesscro
19th August 2011, 05:48 PM
1) Does the ini updater work? It looks like it should.

INI is updated always i use it...

2) Does the updater give you the message and add an item to the notification queue? It looks like it should.

it appear autoupdater script seems to be not give a message like i add

3) This one is a little harder for me to follow, but I suspect it. You can add messages to the script to track its progress.
I do things like message("HERE") or message("Source is: " source) and so on.
Does the data in the registry get updated, but not changed on the screen?

I think, you re right i will track script step to see where i made an error...
Feedback after some test tomorow !

thx Mister RoryB

RoryB
19th August 2011, 06:17 PM
One thing I found:
If( (Rapid1 <= FormatTime("H", Now) AND FormatTime("H", Now) <= Rapid2 )) OR (Rapid3 <= FormatTime("H", Now) AND FormatTime("H", Now) <= Rapid4 ))
An extra ")"
If( (Rapid1 <= FormatTime("H", Now) AND FormatTime("H", Now) <= Rapid2 ) OR (Rapid3 <= FormatTime("H", Now) AND FormatTime("H", Now) <= Rapid4 ))


Bonne chance!

raving_nanza
19th August 2011, 06:18 PM
hey, im working on my weather for my rom, how would i get mortscript to read the time?
(time is not in registry etc)

if its past a certain time i want to run something..

eg,

if time eq XXX
run(YYY)

thanks dudes

RoryB
19th August 2011, 06:37 PM
Read section 9.11 of the manual. It depends on the format you want to use time in. Examples:

int = TimeStamp()
int = MakeTimeStamp( year, month, day [, hour [, minute [, second ]]] )
string = FormatTime( format [, timestamp ] )
GetTime( variable, variable, variable )

lesscro
19th August 2011, 06:52 PM
Bonne chance!

Nice Eyes ! a real Black Hawk !
i tried to insert message :

If( (Rapid1 <= FormatTime("H", Now) AND FormatTime("H", Now) <= Rapid2 ) OR (Rapid3 <= FormatTime("H", Now) AND FormatTime("H", Now) <= Rapid4 ))
utime = Now + (RapidHours*60)*60
Message (" rapidhours " Rapidhours)
Else
utime = Now + (delayHours*60)*60
Message (" delayHours " delayHours)
EndIf

first check is not passed !

i treid another here :
# Start Time Window
If( Activ8 <= FormatTime("H", Now) AND FormatTime("H", Now) < Dactiv8 )
# Check signal strength
If( RegRead( HKLM, "System\State\Phone", "Signal Strength Raw" ) >= SigStrg )
ToggleDisplay(TRUE)
# Only run main task if Wisbar is active
If (ProcExists( "DesktopApp.exe" ))
Sleepmessage (3, "avant le callméteo")
CallScript( "weather_update.mscr" )
Else
utime = Now + (RetryHours*60)*60
Message (" retry " Now )
Call( "NewNotif", utime )
EndIf
EndIf

I really have a problem... i need more investigation because this script is guilty !
But you are so a brain mortscripter, then i have a problem to follow the entire road !

Next tomorrow, i will start from the beginning !

THX again !

hey, im working on my weather for my rom, how would i get mortscript to read the time?
(time is not in registry etc)

if its past a certain time i want to run something..

eg,

if time eq XXX
run(YYY)

thanks dudes

Hi raving_ranza !

Try this to begin

Read your curren time :

Time = TimeStamp()
HourMinute = FormatTime( "H:i" )


HourMinute will return sometin in 24h Clock format !


From manual :
9.11.1 Unix timestamp (TimeStamp)
int = TimeStamp()
int = MakeTimeStamp( year, month, day
[, hour [, minute [, second ]]] )

Returns the current time in seconds since 01/01/1970 (aka Epoch).
TimeStamp() returns the value for the current system time, MakeTimeStamp(...) for the given
date/time combination. If you omit time parameters, “0” is assumed, so if you omit all three of
them, midnight is used.

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”)

raving_nanza
19th August 2011, 07:17 PM
KK, ill check out 9.11 now dude, you must get bord of all these questions about scripts LOL :D

im rewriting my weather update script so its wrote better and simplified :rolleyes:
*the script vibrates, but no copied file (dejavu!) :confused:

RegReadString("HKCU", "Software\Weather Watcher", "Current", Condition )
If( Condition Eq "Cloudy")
#it is
Copy("\Windows\todayfog.png", "\Program Files\rlToday\default\currentweather.png", "TRUE" )
#file exists in windows dir
#true to overwrite file
EndIf
Vibrate(50)
Redrawtoday

@lesscro
thanks dude, looking into it now :)

RoryB
19th August 2011, 07:33 PM
If you open "\Program Files\rlToday\default\currentweather.png" in file explorer is it the "cloudy" picture? or does it fail to copy?

raving_nanza
19th August 2011, 07:52 PM
WOW, figured out what was sup with the script.. (FACEPALM! :rolleyes:)
the registry was wrong, it needed to be:
RegReadString("HKCU", "Software\Weather Watcher\Current", "Condition", Condition)

sorry :p
fixed now :D LOL


btw i think i have time sorted, if anyone can check this for me please before i do more facepalms ;)

Time = TimeStamp()
HourMinute = FormatTime( "H:i" )
If( TIME > "18:00" )
Vibrate(50)
EndIf
Time = TimeStamp()
HourMinute = FormatTime( "H:i" )
If( TIME < "18:00" )
Vibrate(50)
EndIf

(this is to tell my weather script to change from sun and moon images ;

RoryB
19th August 2011, 08:15 PM
FormatTime gives current time so:
Time = FormatTime( "H:i" )
If( TIME le "06:00" or TIME ge "18:00" )
# Moon
Else
# Sun
EndIfor
Time = FormatTime( "H:i" )
If( TIME ge "06:00" and TIME le "18:00" )
# Sun
Else
# Moon
EndIf

raving_nanza
19th August 2011, 08:40 PM
the weather script seems to be working with:

If( TIME > "18:00" )
#and/or
If( TIME < "18:00" )

but i changed 18 to 20 because 8pm seems better for having a moon.

thanks for all your help dudes!

(this will keep me quiet for a while ;))

lesscro
20th August 2011, 05:39 PM
@ RoryB...

After long search and test using manual and help of friend in Time calculation, i have partially rebuilt from your wx_weather...

A custom version... need still some adjustement in part of Non-Hour usage to return unixtime...

But all other scenario wors actually with autoupdate !

Ini CONFIG : i keep only necessary (for me ! )

# LeSScro Weather
# AutoUpdater v2.21082011
# based on RoryB Script
#---------------------------------

# >!--- defifnition
mort = SystemPath("ScriptExe") & "\" & "MortScript.exe"
script = """" & SystemPath("ScriptPath") & "\" & "weather_autoupdater.mscr" & """"

# >!--- Action
If( Question( "Do you want to stop weather AutoUpdater ?^NL^^NL^Press No to change settings.", "aCute weather updater", "YESNO" ))
RemoveNotifications(mort, script)
message( "Weather updater stopped." )
Else
inifile = SystemPath("ScriptPath") & "\" & "autoupdater.ini"
If( FileExists( inifile ))
ForEach xkey, xvalue in iniKeys( inifile, "Weather Settings" )
[xkey]=xvalue
EndForEach
Delete( inifile )
Else
updateDelay = 2
RetryHours = 0.50
updateStart = 7
updateStop = 22
SigStrg = 45
EndIf

# >!--- user configuration
updateDelay = Input ( "Enter delay hours between each update :^NL^in 24 hr clock (1-23)", "aCute weather updater", FALSE, FALSE, updateDelay )
RetryHours = Input ( "Enter retry delay between each fail ^NL^to start AutoUpdater :^NL^^NL^0.25 = 15 min^NL^0.50 = 30 min^NL^0.75 = 45 min", "aCute weather updater", FALSE, FALSE, RetryHours )
updateStart = Input ( "Enter Start time to update :^NL^in 24 hr clock (1-23)", "aCute weather updater", FALSE, FALSE, updateStart )
updateStop = Input ( "Enter End time to update :^NL^in 24 hr clock (1-23):", "aCute weather updater", FALSE, FALSE, updateStop )
SigStrg = Input ( "Minimum signal strength to try to update :^NL^Signal 0% > 100%", "aCute weather updater", FALSE, FALSE, SigStrg )

# >!--- INI & Registry save
writeFile( inifile, "[Weather Settings]", TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "updateDelay=" & updateDelay, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "RetryHours=" & RetryHours, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "updateStart=" & updateStart, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "updateStop=" & updateStop, TRUE )
writeFile( inifile, "^NL^", TRUE )
writeFile( inifile, "SigStrg=" & SigStrg, TRUE )
writeFile( inifile, "^NL^", TRUE )
RegWriteString ("HKCU", "LeSScro\weather", "AutoUpdater", updateDelay)

# >!--- Launch AutoUpdater Script process
Run( mort, script )
message( "Settings changed and weather AutoUpdater started.", "aCute weather updater")
EndIf

AutoUpdater (call my last script to manage weather action using JMLMeteo) and Add Mort to Notification queue :
# LeSScro Weather
# AutoUpdater v2.21082011
# based on RoryB Script
#---------------------------------

# ErrorLevel("off")

# >!--- defifnition
inifile = SystemPath("ScriptPath") & "\" & "autoupdater.ini"
Current = TimeStamp()
Tomorrow = Current + 86400
# >!--- Settings Reader
ForEach xkey, xvalue in iniKeys( inifile, "Weather Settings" )
[xkey]=xvalue
EndForEach


# >!--- Check Hour & Signal Strenght
If( updateStart <= FormatTime("H", Current) AND FormatTime("H", Current) < updateStop )
# >!--- Check signal strength
If( RegRead( HKLM, "System\State\Phone", "Signal Strength Raw" ) >= SigStrg )
ToggleDisplay(TRUE)
If (ProcExists( "DesktopApp.exe" ))
updatetime = FormatTime("H:i", Current + (updateDelay*3600))
unixformat = Current + (updateDelay*3600)
CallScript( "weather_update.mscr" )
Call( "NextUpdate" )
Else
Message ("Please start aCute skin", "aCute by LeSScro (c)")
Exit
EndIf
Else
updatetime = FormatTime("H:i", Current + ((RetryHours*60)*60))
unixformat = Current + ((RetryHours*60)*60)
Call( "NextUpdate" )
EndIf
Else
# >!--- if time is outside window of activation reset to start 1/2 hour after activation hour set in Activ8
If( updateStop <= FormatTime("H", Current) )
updatetime = MakeTimeStamp( FormatTime("Y", Tomorrow ), FormatTime("m", Tomorrow ), FormatTime("d", Tomorrow ), updateStart, 30 )
Call( "Nextupdate")
ElseIf( FormatTime("H", Current) < updateStart )
updatetime = MakeTimeStamp( FormatTime("Y", Current), FormatTime("m", Current), FormatTime("d", Current), updateStart, 30 )
Call( "Nextupdate")
EndIf

EndIf


# >!--- Sub notfification Queue
Sub NextUpdate
mort = SystemPath("ScriptExe") & "\" & "MortScript.exe"
script = """" & SystemPath("ScriptPath") & "\" & SystemPath("ScriptName") & SystemPath("ScriptExt") & """"
# >!--- kill any lingering notification
RemoveNotifications(mort, script)
# >!--- set notification to run at next updatetime
RunAt( unixformat, mort, script)
RegWriteString ("HKCU", "LeSScro\weather","nextupdate", updatetime)
EndSub


And last sript not interesting in this part of procedure !


Result on my future new skin :

http://www.graphiteams.be/upload/images/screen006.png

EDIT /

Final part of "OUT Update HOURS" with correct updatetime registry entry :

• Change from previous auto_updater.mscr this lines :

If( updateStop <= FormatTime("H", Current) )
unixformat = MakeTimeStamp( FormatTime("Y", Tomorrow ), FormatTime("m", Tomorrow ), FormatTime("d", Tomorrow ), updateStart, 30 )
updatetime = FormatTime("d/m" & " " & "H:i", unixformat)
Call( "Nextupdate")
ElseIf( FormatTime("H", Current) < updateStart )
unixformat = MakeTimeStamp( FormatTime("Y", Current ), FormatTime("m", Current ), FormatTime("d", Current), updateStart, 30 )
updatetime = FormatTime("d/m" & " " & "H:i", unixformat)
Call( "Nextupdate")
EndIf

Thx RoryB, for your script, a great piece of Mortscript ONE AGAIN !

Have fun !

okiookio
9th September 2011, 04:23 PM
Please help me !!! :(

how to get the information (used / free / total memory) of storage and storage card?

raving_nanza
9th September 2011, 04:46 PM
duno about storage card but...


9.25 Memory
9.25.1 Available main memory (FreeMemory)
int = FreeMemory()
Returns the available main memory in kilobytes.
Devices with an older system than Windows Mobile 5 dynamically split the device's memory
between memory for programs (FreeMemory()) and a “RAM disk” for the main directory
(FreeDiskSpace("\")).
9.25.2 Size of the main memory (TotalMemory)
int = TotalMemory()
Returns the total size of the main memory in kilobytes.

okiookio
9th September 2011, 05:36 PM
duno about storage card but...


9.25 Memory
9.25.1 Available main memory (FreeMemory)
int = FreeMemory()
Returns the available main memory in kilobytes.
Devices with an older system than Windows Mobile 5 dynamically split the device's memory
between memory for programs (FreeMemory()) and a “RAM disk” for the main directory
(FreeDiskSpace("\")).
9.25.2 Size of the main memory (TotalMemory)
int = TotalMemory()
Returns the total size of the main memory in kilobytes.
so thank


int = FreeDiskSpace( <directory> [, BYTES|KB|MB|GB] ) (max. 2147483647)
int = TotalDiskSpace( <directory> [, BYTES|KB|MB|GB] ) (max. 2147483647)

i got it :

##### Creat by OkiookiO #####
##### Apologize_To_love_tn@yahoo.com.vn#####
##### diskinfor gadget - Windows 7 theme#####

freedevice = FreeDiskSpace( "\",MB)
totaldevice = TotalDiskSpace( "\",MB)

freestoragecard = FreeDiskSpace( "\storage card\",MB)

totalstoragecard = TotalDiskSpace( "\storage card\", MB)

BigMessage(" Your Disk : ^NL^ + "&freedevice&"/"&totaldevice&"MB free in storage ^NL^ + " &freestoragecard&"/"&totalstoragecard &" MB free in storage card"," OkiookiO")
exit

http://cC0.upanh.com/27.718.34992949.mWn0/sd09091101.jpg

okiookio
9th September 2011, 05:41 PM
and now , Please help me change calendar to lunar

jwoegerbauer
10th September 2011, 07:07 PM
A moon phase calculator written in 'C' (two methods) you find here:
http://www.voidware.com/moon_phase.htm
It's not difficult to transform 'C' into 'MortScript'.

okiookio
11th September 2011, 10:55 AM
A moon phase calculator written in 'C' (two methods) you find here:
http://www.voidware.com/moon_phase.htm
It's not difficult to transform 'C' into 'MortScript'.

Thank :D
i'm bad in C :D

but i have a new way to get it ... but..... i have a trouble @@'


Mort :
+ var :
-ngayam is lunar day
-thangam is lunar month
- songay the length of the lunar month ( 29 or 30 days )

-the day end of a month in lunar - > calendar is cuoithang :D
.................................... 29/8 - > 26/9 ( 26 is cuoithang )

I will take this approach in 20 years :D for may theme ( i write theme for my phone :D )
and if you want more , you will be update the .ini file





##### Creat by OkiookiO #####
##### Apologize_To_love_tn@yahoo.com.vn#####
##### Calendar gadget - Windows 7 theme#####

### get day of week
GetTime( H,i,s,d,m,Y )
y-= (14-m)/12
m+= 12*( (14-m)/12 ) -2
w= ( d + y + y/4 - y/100 + y/400 + ( 31*m )/12 ) mod 7
dow=array("sunday","monday","tuesday","wednesday","thurday","friday","saturday")
For i = 1 to7 step 1
if (i=w+1)
w=dow[i]
endif
Next

#### get lunar day

GetTime( H,i,s,d,m,Y )
thangam = IniRead("E:\MY DOCUMENTS\My Home Screens\1 DESKTOP\Build\weather\"&Y&".ini",m,"thangam")
songay = IniRead("E:\MY DOCUMENTS\My Home Screens\1 DESKTOP\Build\weather\"&Y&".ini",m,"songay")
cuoithang = IniRead("E:\MY DOCUMENTS\My Home Screens\1 DESKTOP\Build\weather\"&Y&".ini",m,"cuoithang")

if (d<cuoithang)
ngayam= songay- (cuoithang-d)
else
if (d=cuoithang)
ngayam=cuoithang
else
ngayam= d-cuoithang
thangam=thangam+1
endif
endif

BigMessage("today is "&H&":"&i&":"&s&"/"&w&"/"&d&"/"&m&"/"&Y&"^NL^ in lunar :"&ngayam&" / "& thangam )
exit
####


2011.ini file


[09]
thangam=8
songay=29
cuoithang=26


[10]
thangam=9
songay=30
cuoithang=26

[11]
thangam=10
songay=29
cuoithang=24

[12]
thangam=11
songay=30
cuoithang=24

jwoegerbauer
11th September 2011, 12:13 PM
A script I wrote to show a moon shape image related to current date. It may serve as a template.

#MoonImageApp.mscr (for MioPocket 4.0)
################################################## ###############################
#
#Purpose: Calculates the moon shape (0-27)
#0 => new moon.
#and
# a. changes the (default) iPT-icon shown accordingly
# b. shows in a message window date of next full moon if icon is tapped
#
#Prerequisites: In MioPocket 4.0
# a. this script must be located in \Scripts
# b. in folder \Skin\iPhoneToday\Icons must exist subfolder \MoonImages with
# the two subfolders \NH and \SH
# c. in folder \Skin\iPhoneToday\Icons\MoonImages must exist at least an icon named "moon.png" (placeholder)
# d. in config-file \Skin\iPhoneToday\icons.xml must exist an entry
# <icon name="MoonImage" image="..\Icons\MoonImages\moon.png" exec="..\..\Scripts\MoonImageApp.mscr" animation="0" />
#
#Parameters: none
#
#Usage: CallScript("MoonImageApp.mscr"), best done from within "Initialize.mscr"
#
################################################## ################################
#
#Version: 1.0.0
#Author: jwoegerbauer
#License: GNU GPL Version 3
#
#Credits: michoob (xda-developers)
# jjmilton (http://rotlaus-software.de/forum/index.php?PHPSESSID=062927c481c9ca7e7e085d03e8b5df 83&topic=196.msg3391#msg3391)
#
################################################## ################################
#
Include("Variables.mscr")
Call("Variables_Common")
#
################################################## ################################
ErrorLevel("warn")
Local(NH, moonimagesfolder, regkey, time, day, oldday, month, year, val, \
lastshape, moondeficon, moonnewicon, skin, nextfullmoon)


#Set hemisphere from which moon by default is viewn by user
#NH => northern hemisphere
#SH => southern hemisphere
NH = TRUE
#
############################# DO NOT CHANGE ANYTHING BELOW #######################
skin = SkinFolder\"iPhoneToday"
moondeficon = skin\"Icons\MoonImages\moon.png"
cfgfile = skin\"icons.xml"
moonimagesfolder = NH ? skin\"Icons\MoonImages\NH" : skin\"Icons\MoonImages\SH"
If (NOT DirExists(moonimagesfolder) || NOT FileExists(moonimagesfolder\"*.png"))
Exit
EndIf
regkey = "Software\jwoegerbauer\MoonImageApp"
If(NOT RegValueExists("HKCU", regkey, "NextFullMoon"))
oldday = 0
Else
oldday = RegRead("HKCU", regkey, "OldDay")
EndIf
time = TimeStamp()
day = FormatTime("d", time)
If (day <> oldday)
RegWriteDword("HKCU", regkey, "OldDay", day)
month = FormatTime("m", time)
year = FormatTime("y", time)
# adjust for leap years
If (NOT (year AND 3))
day += 1
EndIf
If ((year MOD 100) = 0)
day -= 1
EndIf
If (month = 1)
month = 3
ElseIf (month = 2)
month = 4
EndIf
val = year MOD 19
If (val > 9)
val -= 19
EndIf
val *= 11
val = val MOD 30
val = 1.0 * val + day + month - 8.3
val = (val + 30) MOD 30
If (val = 15)
val = 14
ElseIf (val = 30)
val = 29
EndIf

If(NOT RegValueExists("HKCU", regkey, "LastShape"))
lastshape = 1000
Else
lastshape = RegRead("HKCU", regkey, "LastShape")
EndIf
# prevent doing things twice
If(val <> lastshape)
RegWriteDWord("HKCU", regkey, "LastShape", val)
moonnewicon = moonimagesfolder\"moon" & val & ".png"

If(FileExists(moonnewicon))
# save image
Copy(moonnewicon, moondeficon, TRUE)
# force re-load the moon icon
@UpdateIcon(Array(0, 0, "MoonImage", moondeficon), cfgfile, FALSE)
EndIf
EndIf
# compute date of next full moon and store it
RegWriteString("HKCU", regkey, "NextFullMoon", @ComputeNextFullMoonDate(time, val))
EndIf
BigMessage("^CR^Next full moon:^NL^" & RegRead("HKCU", regkey, "NextFullMoon"))
Exit

Sub ComputeNextFullMoonDate(time, val)
Local(day, month, year)
If (val = 15)
val = 0
EndIf
While (val<>15)
time = time + 86400
day = FormatTime("d",time)
month = FormatTime("m",time)
year = FormatTime("y",time)
If (month = 1)
month = 3
ElseIf (month = 2)
month = 4
EndIf
val = year MOD 19
If (val > 9)
val -= 19
EndIf
val *= 11
val = val MOD 30
val = 1.0 * val + day + month - 8.3
val = (val + 30) MOD 30
EndWhile
Return(FormatTime("d/m/Y", time))
EndSub

Sub UpdateIcon(iconinfo, xmlfile, wait)
Local(regkey)
xmlfile = IsEmpty(xmlfile) ? cfgfile : (FileExists(xmlfile) ? xmlfile : "")
If(xmlfile eq "")
ExitSub(0)
EndIf
iconinfo = @FindIconPos(iconinfo, xmlfile)
If (iconinfo[1] && iconinfo[2])
wait = IsEmpty(wait) ? FALSE : wait
regkey = "Software\iPhonetoday"
RegWriteDWord("HKLM", regkey & "\icon0", "nScreen", iconinfo[1])
RegWriteDWord("HKLM", regkey & "\icon0", "nIcon", iconinfo[2])
RegWriteString("HKLM", regKey & "\icon0", "strName", iconinfo[3])
RegWriteString("HKLM", regkey & "\icon0", "strImage", iconinfo[4])
RegWriteDWord("HKLM", regkey, "reloadIcon", 1)
If(HiveRegistry)
RunWait(ProgramsFolder\"TroNik\RegFlushKey.exe")
Else
Sleep 500
EndIf
If (wait)
While (RegRead("HKLM", regkey, "reloadIcon") && RegKeyExists("HKLM", regkey & "\icon0"))
Sleep 200
EndWhile
EndIf
ExitSub(1)
EndIf
Return(0)
EndSub

Sub FindIconPos(iconinfo, xmlfile)
#this searches iPT's icons.xml for the passed icon name and, if found, returns array passed
#but now filled up with screen's number and icon's position within screen
Local(xmlcontents, nscreen, nicon, inscreen, line)
If(xmlfile ne "")
xmlcontents = ReadFile(xmlFile)
# check whether icon already exists
If(Find(xmlcontents,iconinfo[3]))
xmlcontents = Split(xmlcontents, "^LF^")
nscreen = 0
inscreen = FALSE
ForEach line in Array(xmlcontents)
If(Find(line, "<screen"))
nscreen += 1
nicon = 0
inscreen = TRUE
ElseIf(Find(line, "</screen"))
inscreen = FALSE
EndIf
If(inscreen && NOT Find(line, "<screen"))
nicon += 1
If(Find(line, iconinfo[3]))
iconinfo[1] = nscreen
iconinfo[2] = nicon
Break
EndIf
EndIf
EndForEach
EndIf
EndIf
Return(iconinfo)
EndSub
Of course you need the 28 (56) images. 28 images I have attached.

lesscro
11th September 2011, 01:18 PM
If you want a code ready to use you can serach about themeChanger for iGO 8 ...

Some way to calculate Lunar phase...

okiookio
30th September 2011, 09:21 AM
Please help me :
ex1 :+how can i use mortscript to make a dial call , end call and check the calling are connected or not connected ?

ex2 : use mortscript to Disconnect Cellular Data ( when i use GPRS/EDGE/3G ...)

lesscro
30th September 2011, 09:34 AM
about Data connection, i use simple method (universal on all device, because lot of EXE but still incompatibility with some device) :

# LeSScro Wireless Suite
#---------------------------------

# >!--- definition

DataState=RegRead("HKLM", "System\State\Connections\Cellular", "Count" )

If (Status eq "")

If (DataState eq "0")
Vibrate (200)
Connect ("Orange World")
Sleep(1000)
Else
Vibrate (200)
Runwait(SystemPath("ScriptPath")\"radiooff.exe")
Runwait(SystemPath("ScriptPath")\"radiooff.exe")
Sleep(2000)
EndIf
Else

If (DataState eq "0")
Vibrate (200)
Connect ("The Internet")
Sleep(1000)
Else
Vibrate (200)
Runwait(SystemPath("ScriptPath")\"radiooff.exe")
Runwait(SystemPath("ScriptPath")\"radiooff.exe")
Sleep(2000)
EndIf
EndIf

Exit
#Data = 0 Off
#Data = 1 On

RADIO ON/OFF can be found here extract exe from CAB : edsubsoft_radio_on_off.cab (http://forum.xda-developers.com/attachment.php?attachmentid=286200&d=1267139937)

okiookio
2nd October 2011, 04:55 PM
what happen with the "Break"?????

when i run my script , have an error :
---------------------------
Error
---------------------------
Unknown command 'break'

Line 15 (E:\MY DOCUMENTS\My Mort Script Project\java manager\Dragone22.mscr):
Break
---------------------------
OK
---------------------------


type = " *.mf"
document = SelectFile("Chọn file Java",FALSE,type)
a=readfile(document)
writefile("temp.tmp",a,false,"unicode-prefix")

is_empty = readline("temp.tmp")
While( NOT IsEmpty(is_empty) )
line = ReadLine( "temp.tmp")
check = find(line,"MIDlet-Name")
if(check<>0)
L=length(line)
name=substr(line,13,L)
message(name)
Break
endif
EndWhile
delete("temp.tmp")
message(name)
exit

jwoegerbauer
2nd October 2011, 05:36 PM
This piece of code by nature runs only once

is_empty = readline("temp.tmp")
While( NOT IsEmpty(is_empty) )
...
EndWhile

but this piece of code runs unless EOF is reached

....
writefile("temp.tmp",a,false,"unicode-prefix")
Sleep 1000
line = ReadLine( "temp.tmp")
While(NOT IsEmpty(line))
If(Find(line,"MIDlet-Name"))
name=SubStr(line,13,Length(line))
Message(name)
EndIf
line =ReadLine("temp.tmp")
EndWhile
delete("temp.tmp")
....

and you don't need a Break

CLHatch
2nd October 2011, 05:49 PM
what happen with the "Break"?????

when i run my script , have an error :

jwoegerbauer already posted code that doesn't require a "break" statement, but as to why you got the error... I'm betting you're not using a beta version of MortScript. The "break" and "continue" statements were added in the betas (after v4.2). Here's the post on Mort's forum with the last version (v4.3b15... was a while ago, seems he may have stopped working on it... I think he went to Android):
http://www.sto-helit.de/forum/viewtopic.php?p=12590#p12590

okiookio
3rd October 2011, 03:58 PM
This piece of code by nature runs only once

is_empty = readline("temp.tmp")
While( NOT IsEmpty(is_empty) )
...
EndWhile

but this piece of code runs unless EOF is reached

....
writefile("temp.tmp",a,false,"unicode-prefix")
Sleep 1000
line = ReadLine( "temp.tmp")
While(NOT IsEmpty(line))
If(Find(line,"MIDlet-Name"))
name=SubStr(line,13,Length(line))
Message(name)
EndIf
line =ReadLine("temp.tmp")
EndWhile
delete("temp.tmp")
....

and you don't need a Break

wow..........:D thanks bro ! that 's good idea ^^!
jwoegerbauer already posted code that doesn't require a "break" statement, but as to why you got the error... I'm betting you're not using a beta version of MortScript. The "break" and "continue" statements were added in the betas (after v4.2). Here's the post on Mort's forum with the last version (v4.3b15... was a while ago, seems he may have stopped working on it... I think he went to Android):
http://www.sto-helit.de/forum/viewtopic.php?p=12590#p12590

OH i dont think so
the error appears when I use V4.3b15 !!!!! ;)
Errors occur when not using autorun.exe file in the package!
using the break command, you must rename the autorun.exe same as the name of the . mscr file
eg okiookio.mscr, rename autorun.exe => okiookio.exe
when running , you must use the . exe file

jwoegerbauer
3rd October 2011, 05:50 PM
jwoegerbauer already posted code that doesn't require a "break" statement, but as to why you got the error... I'm betting you're not using a beta version of MortScript. The "break" and "continue" statements were added in the betas (after v4.2). Here's the post on Mort's forum with the last version (v4.3b15... was a while ago, seems he may have stopped working on it... I think he went to Android):
http://www.sto-helit.de/forum/viewtopic.php?p=12590#p12590


OH i dont think so
the error appears when I use V4.3b15 !!!!! ;)
Errors occur when not using autorun.exe file in the package!
using the break command, you must rename the autorun.exe same as the name of the . mscr file
eg okiookio.mscr, rename autorun.exe => okiookio.exe
when running , you must use the . exe file

@okiookio, this observations to me give no sense at all, because (renamed) AUTORUN.exe - from the MortScript v4.3b15 package - does nothing else but calling MortScript.exe passing as parameter (renamed) script's name, ie (renamed) AUTORUN.exe in no case parses and/or executes (renamed) AUTORUN.mscr, it's MortScript.exe which does the job.

okiookio
3rd October 2011, 07:35 PM
@okiookio, this observations to me give no sense at all, because (renamed) AUTORUN.exe - from the MortScript v4.3b15 package - does nothing else but calling MortScript.exe passing as parameter (renamed) script's name, ie (renamed) AUTORUN.exe in no case parses and/or executes (renamed) AUTORUN.mscr, it's MortScript.exe which does the job.

I can't understand what you are going to say (I speak english not good)
but sometimes when i make a cab file ( it use mort script ), I add mort, if script use Zip/UnZip command , and rename autorun.exe to <name off script without ".mscr" >.exe and creat shortcut to the <name off script without ".mscr" >.exe
It run OK ! don't need ínstall mortscript on device :D

......... i have a project for Java on WM6.5 standard , in that software , I'm using the <name off script without ".mscr" >.exe , if don't use its, i can't unzippath and use Break command but.... when using copy/xcopy/move/... it don't auto creat new folder for copy/move/ ... to fix it , I make tha folder befor use copp/move... command ( MkDir command )

CLHatch
4th October 2011, 04:41 AM
I can't understand what you are going to say (I speak english not good)
but sometimes when i make a cab file ( it use mort script ), I add mort, if script use Zip/UnZip command , and rename autorun.exe to <name off script without ".mscr" >.exe and creat shortcut to the <name off script without ".mscr" >.exe
It run OK ! don't need ínstall mortscript on device :D

......... i have a project for Java on WM6.5 standard , in that software , I'm using the <name off script without ".mscr" >.exe , if don't use its, i can't unzippath and use Break command but.... when using copy/xcopy/move/... it don't auto creat new folder for copy/move/ ... to fix it , I make tha folder befor use copp/move... command ( MkDir command )
Makes perfect sense, actually... What the Autorun.exe renamed does is execute MortScript.exe for you, passing the script name to it. Thing is, it first searches for MortScript.exe in the folder that the Autorun.exe is in. The fact that the script still runs if you don't use the Autorun.exe tells me that you DO have MortScript installed. And the fact that it gives an error on Break tells me that the version installed is not the beta. It's not that it is required that you use the Aurorun.exe to have Break work, it is the fact that the installed version of MortScript is not the beta, and that version gets run instead of the copy in the script's folder.

Mister B
11th October 2011, 05:23 PM
Couple of script ideas to enable HD2 flash when power low.
First script gives you a status of flash & an option to turn flash back on if it is indeed off.

Second script could be used to launch camera & will turn flash back on before starting camera & can be used to replace current Camera shortcut.

If (RegRead( "HKLM", "Drivers\BuiltIn\Battery", "FlashLightPowerUnavailable" ) EQ 1)

X =Question ("Battery low! Camera Flash Status is: Deactivated. Activate Flash ?" , " FLASH STATUS !", "YESNO")
If( x = 1)

RegWriteDWord( "HKLM", "Drivers\BuiltIn\Battery", "FlashLightPowerUnavailable",0 )
EndIf

Else

Message( "Camera Flash is currently: Activated" , " FLASH STATUS !")
EndIf

If (RegRead( "HKLM", "Drivers\BuiltIn\Battery", "FlashLightPowerUnavailable" ) EQ 1)

RegWriteDWord( "HKLM", "Drivers\BuiltIn\Battery", "FlashLightPowerUnavailable",0 )

Sleep 200

Run ("\Windows\Camera.exe","i")

Else

Run ("\Windows\Camera.exe","i")
EndIf

jmses
5th November 2011, 01:16 PM
Hello friends,

I have a problem with a background mortscript that it is driving me crazy.

I have the typical background script that does some stuff, sleeps for a while and does this again and again:


while ( 1 )
do some checks
endwhile


The problem is that when I suspend the PDA the script seems to suspend until I wake it up again. I put a debug trace writing a timestamp to a file and I realized that it was only written if the PDA was alive. How can I make the script to run in background even when the PDA is in suspend mode?

The PDA is an HTC Touch Diamond2 (Topaz) with a WM 6.5 official ROM and I am using Mortscript 4.3

Thanks in advance,
Javier

RoryB
5th November 2011, 02:28 PM
Hello friends,

I have a problem with a background mortscript that it is driving me crazy.

I have the typical background script that does some stuff, sleeps for a while and does this again and again:


while ( 1 )
do some checks
endwhile


The problem is that when I suspend the PDA the script seems to suspend until I wake it up again. I put a debug trace writing a timestamp to a file and I realized that it was only written if the PDA was alive. How can I make the script to run in background even when the PDA is in suspend mode?

The PDA is an HTC Touch Diamond2 (Topaz) with a WM 6.5 official ROM and I am using Mortscript 4.3

Thanks in advance,
JavierTry to use the notification queue (RunAt) method. Search this thread and read the wiki link in my sig

jmses
5th November 2011, 05:30 PM
Try to use the notification queue (RunAt) method. Search this thread and read the wiki link in my sig

Great! I have had to re-write almost all my script but I think that now it is working. Nevertheless, I still have some silly things to sort out:
- Is there a way to get rid of the annoying spinning wheel each time the script executes?
- A piece of the script used timesynctz app to sync time every X minutes. Now, if the clock is off the script will not execute (al least, when it was supposed to).

In any case, those are things I can live with. I will try to find out a way to deal with them.

Thank you very much!
Javier

RoryB
5th November 2011, 06:08 PM
Great! I have had to re-write almost all my script but I think that now it is working. Nevertheless, I still have some silly things to sort out:
- Is there a way to get rid of the annoying spinning wheel each time the script executes?
- A piece of the script used timesynctz app to sync time every X minutes. Now, if the clock is off the script will not execute (al least, when it was supposed to).

In any case, those are things I can live with. I will try to find out a way to deal with them.

Thank you very much!
JavierUnless you call for the ShowWaitCursor in your script it is probably an exe file you run causing the spinning wheel. If you are not using runwait you could try adding HideWaitCursor after you run the command to stop it.

You may need to share your code so others here can review and make suggestions for the fixes you want.

jmses
5th November 2011, 07:46 PM
Unless you call for the ShowWaitCursor in your script it is probably an exe file you run causing the spinning wheel. If you are not using runwait you could try adding HideWaitCursor after you run the command to stop it.

Thanks again. I also suspect of the exe files. I use three of them:
- VJVolubilis.exe
- tel.on-off_100.exe
-TimeSyncTZ.exe
I am going to test the script split in pieces to see if one of them is the guilty.

You may need to share your code so others here can review and make suggestions for the fixes you want.

Well, the script is quite a bit personalized to solve some problems I have with the PDA. It all began with problems with the Bluetooth and then I added some additional things.

Here it is:


BluetoothState = RegRead("HKLM", "System\State\Hardware", "Bluetooth")
if ( (BluetoothState <= 8) and FileExists("\BTon") )
run("\Archivos de programa\vijay555\VJVolubilis\VJVolubilis.exe","-blueon")
Elseif ( (BluetoothState > 8) and NOT(FileExists("\BTon")) )
run("\Archivos de programa\vijay555\VJVolubilis\VJVolubilis.exe","-blueoff")
EndIf

PhoneState = RegRead("HKLM", "System\State\Phone", "Status")
if (PhoneState = 3145760 or PhoneState = 3145824 or \
PhoneState = 16777248 or PhoneState = 16777376 or \
PhoneState = 16777440 or PhoneState = 16777312 or \
PhoneState = 2097184 or PhoneState = 2097248 \
)
run ("\Windows\tel.on-off_100.exe")
Sleep(4000)
run ("\Windows\tel.on-off_100.exe")
endif

h=formatTime("H")
m1=substr(FormatTime("i"),1,1)
m2=substr(FormatTime("i"),2,1)
if (m2="0" or m2="1" or m2="2")
if (h="23" and ProcExists("z7client.exe"))
kill("z7wd.exe")
kill("z7client.exe")
kill("z7wd.exe")
kill("z7client.exe")
run("\Archivos de programa\vijay555\VJVolubilis\VJVolubilis.exe","-gprsoff")
SetBacklight(0,0)
endif

HandsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
if (h="04" and m1="0" and FileExists("\BTon") and HandsFreeState<>1)
run("\Archivos de programa\vijay555\VJVolubilis\VJVolubilis.exe","-blueoff")
sleep(5000)
run("\Archivos de programa\vijay555\VJVolubilis\VJVolubilis.exe","-blueon")
endif

run("\Archivos de programa\DaveShaw\TimeSyncTZ\TimeSyncTZ.exe", "silent /debug- /silentdelay:0 /autoconnect-")
sleep(20000)
kill("TimeSyncTZ.exe")
endif

HandsFreeState= RegRead("HKLM", "System\State\Hardware", "Handsfree")
removeNotifications(systempath("ScriptExe")&"\Mortscript.exe", """\Archivos de programa\Bluetooth\check.mscr""")
runat(timestamp()+30,systempath("ScriptExe")&"\Mortscript.exe", """\Archivos de programa\Bluetooth\check.mscr""")


The first if clause is to test if Bluetooth is working. I use a file as a flag. This is because sometimes Bluetooth goes down when it is connected to the Bluetooth car kit of one of my cars.

The second is due to problems with the Bluetooth car kit of my other car. It is an RSAP device and I realized that when the PDA disconnected from it, it sometimes managed to connect to the mobile network and sometimes it didn't. So it checks for some phone statuses and it restarts the phone if needed.

The third if clause is to switch off the 3G connection and push mail system at night. It also restart Bluetooth (just in case) and lastly it syncs time if there is a connection established (if not, it does nothing).

What worries me now is the drain of battery. I hope the script does not require too much resources.

Regards,
Javier

RoryB
5th November 2011, 09:35 PM
It should actually use less battery because it does not use battery in between "runs".

Do you really need to resync time multiple times every day?

jmses
5th November 2011, 09:46 PM
Do you really need to resync time multiple times every day?

Maybe not. If I see that it is consuming too much battery, it will be the first thing I will cut off.

jmses
7th November 2011, 07:01 PM
Hello,

I can't make the command playSound(wave) work. A simple script with the following line does nothing:
playSound("\Windows\Voicbeep.wav")

I have found the following workaround:
run("\Windows\wmplayer.exe","\Windows\Voicbeep.wav")
But I don't like it because it shows up the Windows Media window.

Is there any solution to make playSound() work?

My PDA is an HTC Touch Diamond2 (Topaz) with a WM 6.5 official ROM and I am using Mortscript 4.3

Thanks and best regards,
Javier

RoryB
7th November 2011, 07:16 PM
Hello,

I can't make the command playSound(wave) work. A simple script with the following line does nothing:
playSound("\Windows\Voicbeep.wav")

I have found the following workaround:
run("\Windows\wmplayer.exe","\Windows\Voicbeep.wav")
But I don't like it because it shows up the Windows Media window.

Is there any solution to make playSound() work?

My PDA is an HTC Touch Diamond2 (Topaz) with a WM 6.5 official ROM and I am using Mortscript 4.3

Thanks and best regards,
JavierTry PlaySound("Voicebeep")

jmses
7th November 2011, 09:00 PM
Try PlaySound("Voicebeep")

I found it! It was a option in the configuration of the notifications of events. Theres is an option to enable/disable program notifications. After enabling it it has started to work.

Thanks!
Javier

sudist
8th November 2011, 07:41 PM
Hello,

On my Pc in vbs i'll do this:
CreateObject("WScript.Shell").Run "cmd /c netsh.exe wlan connect ssid=LesArcades name=LesArcades"

does anyone knows how to do this with mortscript?

jwoegerbauer
16th November 2011, 03:20 PM
exec="netsh.exe"
params="wlan connect ssid=LesArcades name=LesArcades"
Run(exec,params)

sudist
16th November 2011, 07:26 PM
@jwoegerbauer, thank you

this is working:
exec="c:\windows\system32\netsh.exe"
params="wlan connect ssid=LesArcades name=LesArcades"
Run(exec,params)

HAPKO
20th November 2011, 11:24 AM
hi i need a script when a process stop another one start
when miomap.exe stop TauShell.exe must start

thanks.

jwoegerbauer
20th November 2011, 12:01 PM
Local()
_miomap="<fullfilepathname>\MioMap.exe"
_taushell="<fullfilepathname>\TauShell.exe"
_delay=2000

If(FileExists(_miomap)&&FileExists(_taushell))
While(1)
If((NOT ProcExists(_miomap))&&(NOT ProcExists(_taushell)))
Run(_taushell)
ElseIf((NOT ProcExists(_taushell))&&(NOT ProcExists_(miomap)))
Run(_miomap)
EndIf
Sleep _delay
EndWhile
EndIf

HAPKO
20th November 2011, 12:46 PM
not work
unknown function procexists_
line:
elself((not procexists(_taushell))&&(not...........

jwoegerbauer
20th November 2011, 01:00 PM
OK, my fault, sorry for this. This should do it:

ElseIf((NOT ProcExists(_taushell))&&(NOT ProcExists(_miomap)))

HAPKO
20th November 2011, 01:18 PM
thank you very much work well

jwoegerbauer
18th December 2011, 11:20 AM
OFF-TOPIC

Created an user defined language (UDL) for NotePad++, my favorite editor, thus MortScript-scripts are synthax conformally shown. Look here:

http://forum.xda-developers.com/showthread.php?t=1398438

HTH

lesscro
25th December 2011, 08:04 AM
hi, a part of my weather script need use "connect" feature...

but when connection is unavailable, it return an error like :
Connect interpreter can't...

start seems like that :
If (InternetConnected( "http://www.bing.com" ) = 1 )
Call ("updater")
Else
Call ("connector")
EndIf

If no active connection :
Sub connector
Connect (MyConnect)
Call ("updater")
EndSub
My connect is definied by user using another script, but Connect function return an error if no data connection can be established; how i can chek this value to make something... like report or something like that...

i tried
If (Connect (MyConnect) = 1)
or
If (Connect (MyConnect) = TRUE)
But function is not valide...

any tips ?

jwoegerbauer
25th December 2011, 06:02 PM
Bool = Connected()
Bool = InternetConnected( [ URL ] )

are the only available 2 functions you can check a connection state with.

Connected() only queries state of a RAS-connection („Remote Access“) - returns in case of ActiveSync always TRUE, in case of an internet connection NOT always TRUE, though connection really is established. I would prefer to use InternetConnected().

Try this:

connection = Array(<connection name>,<url>)
If(NOT InternetConnected(connection[2])
Connect(connection[1])
Else
CloseConnection()
Sleep 1000
Connect(connection[1])
EndIf

lesscro
25th December 2011, 08:44 PM
thx i found a tips to perform same thing... with help of 2 friends...

But at this time we can't check if Connect(Name of Connexion) will work or not...

burton74
27th December 2011, 06:35 PM
Please Help!!!

this is ok
Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test "" -body ""Photos "" -attach ""\storage

card\dcim\100media\IMAG0171.jpg"" " )



what is wrong??

f="\storage card\DCIM\100MEDIA\IMAG0171.JPG"
Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach ""&f"" " )

please help!!!!!!

RoryB
27th December 2011, 06:43 PM
Please Help!!!

this is ok
Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test "" -body ""Photos "" -attach ""\storage

card\dcim\100media\IMAG0171.jpg"" " )



what is wrong??

f="\storage card\DCIM\100MEDIA\IMAG0171.JPG"
Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach ""&f"" " )

please help!!!!!!
f is a variable. Do not need quotes

Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach f )

You may need quotes in the string

Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach """ & f & """ )

Sometimes it takes 4 " symbols


Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach """" & f & """" )

burton74
28th December 2011, 07:03 AM
f is a variable. Do not need quotes

Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach f )

You may need quotes in the string

Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach """ & f & """ )

Sometimes it takes 4 " symbols


Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach """" & f & """" )




Thank you ! :)

michoob
28th December 2011, 09:16 AM
Sometimes it takes 4 " symbols
LOL, I enjoyed this explanation! :D
I hope you know what is behind this "sometimes" behavior :p.
Just for information, it is just that to write a quote " within a string which starts and ends with one quote ", you need to enter two quotes "".
If you code Message("any message"), you will pop up the following message:
any message
If you code Message("any message with ""quotes"" inside"), you will pop up the following message:
any message with "quotes" inside
So why sometimes 3 or 4 quotes?
You actually see 4 quotes when you just want to display or concatenate a single quote. Coding Message("""") pops up that:
"
Coding Message("""""") will pop up that:
""
And you will see 3 quotes when displaying quotes in the beginning or the end of a string. Coding Message("""quoted message""") will pop up that:
"quoted message"

So sorry RoryB, but neither of your suggestion will work :(.
Both 3 quotes only and 4 quotes only suggestions have an unclosed string (missing blue quote " in the end):
Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach """ & f & """ )

Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach """" & f & """" )

And as you need the content of the f variable with quotes around it, only this can work:
Run("\Windows\tmail.exe","-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach """ & f & """")

RoryB
28th December 2011, 11:23 AM
Unfortunately I cannot tell you why. I have not been doing much MortScript lately. I just remember sometimes my scripts have not worked until I added a fourth double quote symbol. I answered in a rush. You are correct, three " should create " in the result and four should result in "".

I did realize I had an error in the code. I think it should be:

Run("\Windows\tmail.exe", "-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach """ & f & """" )

Here the four at the end make up the open and close quotes of a string input and the other two inside become a quote. I think this will give a " in front of the value f and one " after the value so the results would be:

-service "web.de" -to "willi@web.de" -subject "Test" -body "Photos" -attach "\storage card\DCIM\100MEDIA\IMAG0171.JPG" )

I could have also written it this way with more code in it:

Run("\Windows\tmail.exe", "-service ""web.de"" -to ""willi@web.de"" -subject ""Test"" -body ""Photos"" -attach " & """" & f & """" )

michoob
28th December 2011, 11:33 AM
Yes, RoryB, I agree with your last post :).

vivekiny2k
17th January 2012, 09:27 PM
when I use tmail.exe this way it takes me to the email screen and I have to press send. is there a way to actually send the email (with the screen being locked, script executing in background)?

howdykeith
17th January 2012, 09:31 PM
when I use tmail.exe this way it takes me to the email screen and I have to press send. is there a way to actually send the email (with the screen being locked, script executing in background)?

You can use CMail.exe (http://forum.xda-developers.com/showpost.php?p=5431240&postcount=15)

By Cyclone: http://forum.xda-developers.com/showthread.php?t=623434

I did... :D

coukou
27th January 2012, 02:51 PM
Hello,

A fiend of my let me his old GPS Magellan RoadMate 1215 to update. That GPS have 32MB RAM and run Navigator software under WinCE 5.0.
I installed iGO8 on his GPS, it works just fine.

Although the Navigator software is old (2007) I don’t intend to delete it. Even better, I wish giving him a choice to run his old Navigator or iGO8.
That GPS have 2 files for the stratup control: Startup.xml and Unit.xml
Starup.xml point in Unit.xml the program to be run.
Stratup:
<Shell>
<Application ID="175" />
</Shell>
Unit.xml:
<?xml version='1.0' encoding='UTF-8'?>
<MagellanGPS>
<ModelName>Magellan® RoadMate</ModelName>
<ModelNumber>1215 EU</ModelNumber>
<ID>732</ID>
<SerialNumber>xxxxxxxxxxx</SerialNumber>
<USVersion>0</USVersion>
<Hardware>
<CodeFlashSize>32</CodeFlashSize>
<NandFlashSize>0</NandFlashSize>
<ProgramRAMSize>26</ProgramRAMSize>
<HDDSize>0</HDDSize>
<SDCardSize>0</SDCardSize>
<CFcardSize>0</CFcardSize>
<PowerStatus>AC</PowerStatus>
</Hardware>
<Application ID="175">
<FileName>Navigator.exe</FileName>
<Path>HDD\App\</Path>
<Bitmap>32x32x16.bmp</Bitmap>
<Version>
<Major>1</Major>
<Minor>23</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
<Application ID="20">
<FileName>mgnShell.exe</FileName>
<Path>HDD\APP</Path>
<Bitmap>32x32x16.bmp</Bitmap>
<Version>
<Major>1</Major>
<Minor>27</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
<Application ID="134">
<FileName>MP3Player.exe</FileName>
<Path>HDD\APP</Path>
<Bitmap>32x32x16.bmp</Bitmap>
<Version>
<Major>1</Major>
<Minor>17</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
<Application ID="135">
<FileName>ceplayer.exe</FileName>
<Path>Windows</Path>
<Bitmap>32x32x16.bmp</Bitmap>
<Version>
<Major>1</Major>
<Minor>17</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
<Application ID="101">
<FileName>Neptune.exe</FileName>
<Path>HDD4\\</Path>
<Bitmap>user.bmp</Bitmap>
<Version>
<Major>1</Major>
<Minor>37</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
<Application ID="133">
<FileName>ShellTest.exe</FileName>
<Path>HDD\\</Path>
<Bitmap>user.bmp</Bitmap>
<Version>
<Major>1</Major>
<Minor>37</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
<Application ID="111">
<FileName>IeSample.exe</FileName>
<Path>Windows</Path>
<Bitmap>32x32x16.bmp</Bitmap>
<Version>
<Major>1</Major>
<Minor>37</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
<Application ID="151">
<FileName>VRServer.exe</FileName>
<Path>HDD\App\</Path>
<Bitmap></Bitmap>
<Version>
<Major>1</Major>
<Minor>37</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
<Application ID="152">
<FileName>BlueSoleil.exe</FileName>
<Path>HDD\App\</Path>
<Bitmap></Bitmap>
<Version>
<Major>1</Major>
<Minor>37</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>
</MagellanGPS>

Also, I wrote a small script Start.mscr to give the choice:
Sleep (1000)

Choice (""," Magellan RodeMate 1200 Start Menu ^LF^ <Annuler L'appareil sera eteint> "," Magellan Navigator "," iGO8 v8.3.2.64827 ", " Redemarrer ", " Eteindre ")
Case(1)
Run ("\HDD\APP\Navigator.exe")
Case(2)
RunWait ("\Storage Card\iGO8\iGO8.exe")
If (not ProcExists(iGO8.exe))
Run ("\HDD\SCRIPT\start.mscr")
EndIf
Case(3)
Run ("\HDD\SCRIPT\Restart.exe")
Case(4)
Run ("\HDD\SCRIPT\Off.exe")
Case(0)
Run ("\HDD\SCRIPT\Off.exe")
EndChoice

#************************************************* ********************
Modified the Starup.xml to: ! <Application ID="154" />
And added the following to the here above Unit.xml
<Application ID="154">
<FileName>Start.mscr</FileName>
<Path>HDD\SCRIPT\</Path>
<Bitmap></Bitmap>
<Version>
<Major>1</Major>
<Minor>37</Minor>
<Internal>0</Internal>
<Build>0</Build>
</Version>
</Application>

To be sure my script works; I run Mortscript.exe and checked the Registry. Mortscript is registered. Then I launch manually the script, it works just fine.
However, when I restart the device with the above, Start.mscr never starts. I suspect Start.mscr must be an .exe file.
So, is there anyhow to compile/convert the above Start.mscr to Start.exe

I'll be grateful if somebody can help me.
Regards

RoryB
27th January 2012, 03:15 PM
In the Mortscript file location there is a file autorun.exe
Copy it and rename the copy to Start.exe and call it in your xml file
It will run the script for you

NOTE: Both Start.exe and Start.mscr have to be in the same folder.

coukou
28th January 2012, 06:38 PM
Many TNX RoryB for the info :D
BTW, the here above menu is very basic. Is anywhere a small graphic menu to get inspiration?

Regards

jwoegerbauer
29th January 2012, 07:30 AM
Is anywhere a small graphic menu to get inspiration?

By-look here: http://forum.xda-developers.com/showthread.php?t=1368340

coukou
29th January 2012, 11:13 AM
TNX jwoegerbauer ;)

howdykeith
29th January 2012, 08:06 PM
By-look here: http://forum.xda-developers.com/showthread.php?t=1368340

Hey that's pretty cool. I will add it to the Mortscript Compendium (http://forum.xda-developers.com/showpost.php?p=5105817&postcount=23).

I was going to mention JMLmenu.exe (http://forum.xda-developers.com/showpost.php?p=5164206&postcount=2) or the JMLMenuSense (http://forum.xda-developers.com/showthread.php?t=885959) or the super cool kvvQuickMenu (http://translate.google.com/translate?hl=en&rurl=translate.google.com&sl=ru&tl=en&u=http://kvv.my1.ru/load/smsspy_sokhranjalka_vkhodjashhikh_sms/6-1-0-57).

Thanks.

seb3773
29th January 2012, 11:40 PM
Hello
I needed a bandwith tester, but couldn't found one... So i decided to write a little script :)

It's very simplistic, but maybe it can be usefull for someone else?
Please be smart, this is my first mortscript script, so maybe it's not the good way to do this, but anyway here it is:


Go=1
While (go=1)
{

Choice( "Bandwith Test","Select a filesize for the test:","[Free -france]- 1 Mo File","[Free -france]- 2 Mo File","[Free -france]- 8 Mo File","[cachefly -US]- 1 Mo File", "[cachefly -US]- 10 Mo File" )
Case( 1 )
testfile= "http://test-debit.free.fr/1024.rnd"
Case( 2 )
testfile= "http://test-debit.free.fr/2048.rnd"
Case( 3 )
testfile= "http://test-debit.free.fr/8192.rnd"
Case( 4 )
testfile= "http://cachefly.cachefly.net/1mb.test"
Case( 5 )
testfile= "http://cachefly.cachefly.net/10mb.test"
Case( 0 )
Exit
EndChoice

timebefore = TimeStamp()
Download( testfile, "\filetest.bdw" )
timeafter = TimeStamp()
Vibrate( 50 )
elapsed= timeafter-timebefore

If( elapsed>60 )
{
timeinmin= Floor (elapsed/60)
timeinsec= elapsed-(timeinmin*60)
}

Else
{
timeinmin=0
timeinsec=elapsed
}
EndIf

szfile= FileSize( "\filetest.bdw" )
bndwith= szfile/elapsed

Message( szfile & "bytes File downloaded in " & timeinmin & "min " & timeinsec & "sec^CR^^LF^^CR^^LF^Bandwith: " & floor(bndwith/128) & "Kbps" ,"Bandwith Test Result" )

Delete( "\filetest.bdw" )

doitagain = Question( question , "Perform another test ?" , "YesNo" )
if (doitagain="No")
{
Go=0
}
EndIf


}
Endwhile




Regards.

coukou
6th February 2012, 12:10 PM
Hello,

I'm writing a small menu and its skin for and old GPS Magellan RoadMate 1215 and I want to add a date and time to the skin. I just noticed that the WinCE 5 of that GPS is "MINIMALIST". There is no Control Panel files.

Anyone can be kind and upload ctlpnl.exe, cplmain.cpl and all *.cpl? I googled these files without success.

Regards

jwoegerbauer
6th February 2012, 01:59 PM
What you are searching for is to be found in the MioPocket 4.0 package:
http://www.gpspassion.com/forumsen/topic.asp?TOPIC_ID=136798

coukou
6th February 2012, 04:28 PM
TNX jwoegerbauer but it's not what I'm looking for.
I know about Miopocket it's a very nice unlock GPS device +Menus +Progs... it is a gasworks regarding what my Magellan 1215 can do. Magellan 1215 have only 32 MB RAM and less than 27 MB free.

Can you help with ctlpnl.exe and cplmain.cpl? Unless a SetDate and Time script file already exists.

Regards

jwoegerbauer
6th February 2012, 06:50 PM
I attached these 2 files taken from a CE 5.0 Sat Nav. HTH

coukou
7th February 2012, 03:59 PM
TNX jwoegerbauer. Unfortunately it doesn't help :(
Infact, ctlpnl.exe, cplmain.cpl must be in Windows folder. As you know It is not possible to write to that folder. Also, I was afraid to brick the device by routing Windows folder to the FlashCard. I route the Windows\Programs to the FlashCard\MyPrograms and wrote the command script as here bellow.
When I launch DateTime.mscr... nothing happens

MyPrograms.reg
[HKEY_LOCAL_MACHINE\System\Explorer\Shell Folders]
"Programs"="\\HDD\\MyPrograms (file://\\HDD\\MyPrograms)"

DateTime.mscr
Run("\HDD\MyPrograms\ctlpnl.exe", "cplmain.cpl,13")

jwoegerbauer
7th February 2012, 04:17 PM
A:

Basically there is no need to redirect \Windows (or parts herefrom) to resident flash, say \HDD\MyWindows. You simply tell OS where to look for CE-system-files if those are not by default to be found in \Windows. The entry in registry herefore is:

[HKEY_LOCAL_MACHINE\Loader], you simply create if it does not exist.

Ex:

[HKEY_LOCAL_MACHINE\Loader]
"SystemPath"=REG_MULTI_SZ: "\HDD\MySytemPath"

B:

In folder \HDD\MyPrograms you additionally can create a shortcut to \HDD\MySystempath\ctlpnl.exe, but there is no need for this, at least I think so.

coukou
7th February 2012, 05:53 PM
Sorry for bothering you, it doesn't help yet :(

The is not taken in account. It's Value DATA must be binary. So, I added a New Key (Multi String) manually
[HKEY_LOCAL_MACHINE\Loader]
Multi String Key: "SystemPath
Data: "\HDD\MySytemPath"

I put ctlpnl.exe and cplmain.cpl in FlashCard\MySystemPath folder modified the command script as here bellow and when I launch DateTime.mscr... still nothing happens

DateTime.mscr
Run("\HDD\MySystemPath\ctlpnl.exe", "cplmain.cpl,13")

jwoegerbauer
7th February 2012, 07:06 PM
http://msdn.microsoft.com/en-us/library/ms886736.aspx:

Unless the full path to the module is specified, Windows CE searches the following path for the module:

The absolute path specified by the lpLibFileName parameter
The .exe launch directory
The Windows directory
ROM DLL files
An OEM-specified search path

The following registry subkey specifies a search path to use with LoadLibrary and CreateProcess:

HKEY_LOCAL_MACHINE\Loader
SystemPath=multi_sz:\\path1\\
\\path2\\

The path is only searched if the path of the file being looked for is not explicitly specified.

The total length of the SystemPath value must not exceed 260 characters. If it does, the path is ignored.

A change to the SystemPath key does not take effect until a Windows CE–based device is reset.

coukou
7th February 2012, 09:04 PM
http://msdn.microsoft.com/en-us/library/ms886736.aspx: HTTP 404

Unless the full path to the module is specified, Windows CE searches the following path for the module:

The absolute path specified by the lpLibFileName parameter
The .exe launch directory
The Windows directory
ROM DLL files
An OEM-specified search path

The following registry subkey specifies a search path to use with LoadLibrary and CreateProcess:

HKEY_LOCAL_MACHINE\Loader
SystemPath=multi_sz:\\path1\\
\\path2\\

The path is only searched if the path of the file being looked for is not explicitly specified.

The total length of the SystemPath value must not exceed 260 characters. If it does, the path is ignored. (40 length multi string)

A change to the SystemPath key does not take effect until a Windows CE–based device is reset. Reset done


I tested the next with the command Run and RunWait without success
DateTime.mscr
Run("\HDD\MySystemPath\ctlpnl.exe", "cplmain.cpl,13")

DateTime.mscr
Run("\Windows\ctlpnl.exe", "cplmain.cpl,13")

coukou
8th February 2012, 09:45 PM
Finally as my WinCE is very MINIMALIST, I leave the date and time setting via the non-exisisting control panel.

I just use the following command SetTime(hour, minute, second, day, month, year )This give the time format as 12 H.

Is there any how to get the Time in 24 H as well as TimeZone? (by registry?)

Regards

jwoegerbauer
9th February 2012, 08:53 PM
Don't know where you retrieve the time from. But each (retrieved) time can be represented in UNIX-time format aka TimeStamp. This in mind it should be easy to format the time. MortScript offers FormatTime() function for such purpose. You use this to create a string value you then split into the 6 time components you finally pass to SetTime().

coukou
10th February 2012, 10:40 AM
I could set 24 Hours time but I leave all about date and time.

As my WinCE is control-panel-less files and certainly other files and functions missed, I noticed after a reboot/reset the date is set to dd/mm/2003 and the time to any. At best the date is not modified and the time is increased by 1 hour:confused:
Regards

mariasx
20th February 2012, 03:32 PM
I created todolist manager with Mortscript. I use it EVERYDAY with my HTC Touch Diamond 1. I use it also on my Windows XP pc.

Now I have about 150 tasks and I have performance issues on my HTC Diamond. I use "foreach record in Array" to parse my data. Right after script starts, parsing is quick, it takes about 2 seconds. But after a while using my todolist manager parsing over the same Array takes more than 10 seconds. Quit the script and start it again helps but it is not sufficient for me. I also rewrote my script to cache some data but I am not happy enough with it.

Any help will be very apreciated

michoob
20th February 2012, 04:23 PM
Hi mariasx, I don't think your problem comes from the "foreach record in Array", but rather from the massive amount of string operations (Replace, Find, SubStr, Split)!
There is definitly something to do around these string operations...

I do not have much time to spend, but an idea might be trying to recode the whole script to avoid using all these string operations, but to use the IniRead and IniWrite functions and to store your data in a .ini file, where you would have a .ini section per your current csv column, and a code for each task... not sure if it would be better.

mariasx
21st February 2012, 02:57 PM
Hi michoob

1. Thank you for answer. I did not change data(Strings operations). I tried to display different lists(Foreach record in Array) and performance was decreasing. So I think there is problem with memory and I do not know how to handle it.

2. How do you think data should be designed in INI file?

like that?

[lorem]
desc=Nam posuere iaculis
status=n
context=movies

[ipsum]
desc=pretium eu leo
status=n
context=movies

michoob
22nd February 2012, 08:30 AM
1. I do not say you change the data, but you obviousely use string operations for the display in your Foreach loop, and that is why performance is decreasing. And it is not decreasing because of memory, but rather because of CPU...
You might try to use MortScript 4.3b15 (http://www.sto-helit.de/forum/download/file.php?id=265) if not already the case, because it is faster.

2. Nope, I would rather see it like this, but then, the data is of course less readable than a csv file (but do yo care?):
[reference]
1=lorem
2=ipsum

[desc]
1=Nam posuere iaculis
2=pretium eu leo

[status]
1=n
2=n

[context]
1=movies
2=movies

RoryB
28th February 2012, 04:13 PM
My Fuze no longer works. I currently have a loner Infuse 4G, but do not know what I will end up with.

I will not be able to continue development of Mortscripts, etc.

Sorry to go, but it has been fun.

I'll keep watching to see if anything comes up I need to respond to.

mariasx
28th February 2012, 08:14 PM
RoryB, it's a pity see You leaving. What will be Mortscript replacement for you? Are you looking for it?

RoryB
28th February 2012, 08:44 PM
RoryB, it's a pity see You leaving. What will be Mortscript replacement for you? Are you looking for it?

The loaner is a Droid, but I do not know what I'll end up with. So I am in limbo.

bbobeckyj
28th February 2012, 09:06 PM
The loaner is a Droid, but I do not know what I'll end up with. So I am in limbo.

Sell it on eBay and get yourself whatever you want.

mariasx
28th February 2012, 09:23 PM
The loaner is a Droid, but I do not know what I'll end up with. So I am in limbo.

I have an Android device too. For a six months I am still looking for Mortscript replacement for Android. I found some candidate like BASIC! + SQL (https://market.android.com/details?id=com.rfo.basic). Even better could be Frink Programming Language (https://market.android.com/details?id=frink.android) but it still do not adequately meets Mortscript quallities.

I need one programming language for phone and desktop and Java is not what I am talking about. Adobe Flex is also an possible alternative.

Maybe Windows 8 will be salvation because it is Intel and also Arm processor compatible. I am curious.

lesscro
11th March 2012, 11:56 AM
Thx for all RoRyB... you help lot of time and insipre me more than lot of time...

See yaaa in other place... ;)

jwoegerbauer
8th April 2012, 07:02 PM
I have a script with ~3,300 lines. Script is organized in parts MAIN and SUBS. Suddenly got error "Sub must not be in control structure". I know this errror only occurs if If/EndIf is not matching. Re-reading the script again and again I didn't find the missing EndIf. Hence decided to write a small script as listet next to make searching for the error cause easier

local()


Thoght I should share this script.