Mortscript Guide   

Mortscript Guide

Postby Fatboyfun » Fri Dec 10, 2010 8:29 pm

[SIZE="150"]Mortscript is the most useful tool an advanced user can have. It can be used to launch applications, change registry entries, change device settings, automate some features, copy files from one place to another, play sounds and lots of other useful stuff, Although it does require you to write your own scripts and know some details about your device, So this guide is intended for advanced users who want a little more from their device.[/size]

WARNING: While Mortscript is a very useful tool to have, It can also allow you to change settings that would stop your device from working, So don't do anything until you have read and understood what each command does and how it is formatted, And definitely DO NOT change the startup sequence of your device until you're 100% sure you know what you're doing. Start out with simple scripts run manually from a icon.

Download Mortscript WinCE version here -> [Please Register or Login to download file]


Archive contents:
Mortscript.exe is the main application.
Script.exe Run this to activate the script.
Script.mscr is just an empty text file, This is where you write your scripts.

Lesson one, Basic Mortscript usage and How to...
This guide lists some of the more common commands that we are interested in, although there are many many more commands, They don't really serve any useful purpose on Windows CE so are omitted.
The most important file inside the archive is Script.mscr, This is where you write your scripts, Just copy and paste whichever commands you need into this file with Notepad and edit them to fit your requirements. Then launching Script.exe will run the script.
You can rename Script.exe and Script.mscr to suit your requirements, Both files need to have the same filename before the extension, ie, Start.exe and Start.mscr or Menu.exe and Menu.mscr, But leave Mortscript.exe as it is. Be careful not to rename Script.mscr to Script.mscr.txt by saving as "All Files", All three files need to be kept together in the same directory.
You can share one Mortscript.exe between several scripts, and run them simultaneously although it's not possible to run the same script twice at the same time.
If you run Mortscript.exe by mistake a dialog box pops up saying something about registering file extensions, Don't worry about this, This is normal.

Lesson two, Basic commands.
# REM statement
# Notes and comments about the script can go here.
# Or experimental lines of code you're working on.


Run Runs an application.
Run ("\Storage Card\Primo\iGO.exe")

RunWait Runs an application and waits until it has closed before continuing the script.
RunWait ("\Storage Card\Navigator\Tomtom Navigator.exe")
Run ("\My Flash Disk\Menu.exe")

Minimize Minimizes the window specified, Opposite of Show.
Minimize ("Garmin Mobile XT")

Show Maximizes the window specified. Opposite of Minimize.
Show ("Garmin Mobile XT")

WaitFor Waits for an application window to appear before continuing. Below Menu.exe is run, When the Window "Menu" appears the script waits for one second then plays Startup.wav
Run ("\My Flash Disk\Menu.exe")
WaitFor ("Menu", 1)
PlaySound ("\Storage Card\Startup.wav")

Sleep Pauses the script for a time specified in milliseconds. (1000 = 1 second) Below Tomtom is run, After it has closed there is a five second wait before the device suspends itself.
RunWait ("\Storage Card\Navigator\Tomtom Navigator.exe")
Sleep 5000
PowerOff

PlaySound Plays a wav.
PlaySound ("\Storage Card\Startup.wav")

SetVolume Sets the volume of your device, 0 to 255.
SetVolume (255)

PowerOff Turns off your device, It normally cannot be woken up again.
PowerOff

Reset This will soft reset your device.
Reset

Exit This simply stops the script and exits.
Exit

Lesson three, Intermediate level commands.
Close Closes an application, Not all applications will accept a close request, Use the window title.
Close ("Tomtom Navigator")

Kill Forces an application to close, Below mnavdce.exe is run, Three seconds after the window for Gopal Navigator appears it is closed, Then iGO Primo runs. Use the .exe name. (Toolhelp.dll needs to be in the Windows directory for this command to work, It is in most (But not all) WinCE versions, WinCE 5 and 6 have different versions and Mortscript will crash with the wrong one.)
Run ("\My Flash Disk\navigation\mnavdce.exe")
WaitFor ("GoPal Navigator", 3)
Kill ("mnavdce.exe")
Run ("\Storage Card\Primo\iGO.exe")

XCopy Copies files from one folder to another. In this example files are copied from \My Flash Disk\Shortcuts to \Windows\Desktop, The *.lnk part means only files with an .lnk extension within the directory are copied. FALSE, FALSE means Do not overwrite and Do not copy sub directories respectively, Replace with TRUE if you want to use these features, i.e. TRUE, FALSE means overwrite but do not copy sub directories, etc...
XCopy ("\My Flash Disk\Shortcuts\*.lnk", "\Windows\Desktop", FALSE, FALSE)
Here all files from \My Flash Disk\Backup are copied to \Windows. Any files already in \Windows will be overwritten and any sub directories will be copied.
XCopy ("\My Flash Disk\Backup\*.*", "\Windows", TRUE, TRUE)

MkDir Creates folders, It is not possible to create more than one folder level at once
To create \My Documents\UserData\Backup, You need to write...
MkDir ("\My Documents\UserData")
MkDir ("\My Documents\UserData\Backup")

You can't just write...
MkDir ("\My Documents\UserData\Backup")
As it will fail.

RedrawToday Refreshes the today screen. Below the wallpaper is removed and the today screen is refreshed.
RegWriteString ("HKCU", "ControlPanel\Desktop", "Wallpaper", "")
RedrawToday

If, EndIf You can use these commands to ask if an application is running. This example checks to see if Garmin Mobile XT is running, If it is, It's shown, And then the script stops, If it isn't then iGO Primo is run instead. For every If there needs to be an EndIf.
If (WndExists("Garmin Mobile XT"))
Show ("Garmin Mobile XT")
Exit
EndIf
Run ("\Storage Card\Primo\iGO.exe")

While, EndWhile Carries out commands only while an application is running, Every While needs an EndWhile, Here Beep.wav plays every sixty seconds while Tomtom is running and then stops when it has been closed. The commands between While and EndWhile are repeated until Tomtom has closed, So a sleep command should be used to slow things down a bit otherwise the device may experience lag.
Run ("\Storage Card\Navigator\Tomtom Navigator.exe")
While (WndExists("Tomtom Navigator"))
PlaySound ("\My Flash Disk\Beep.wav")
Sleep 60000
EndWhile

MouseClick Simulates a tap on the screen, Coordinates are pixels from the top left of the screen.
MouseClick(180,130)

MouseDblClick As above but a double tap.
MouseDblClick(180,130)

Send Can select common options from WinCE dialogue boxes, Allowed options are OK, Cancel, Yes, No.
To press the OK button from mortscript,
SendOK
And to press the Yes button,
SendYes
You can also simulate keystrokes, Up, Down, Left, Right, This emulates the direction pad, and CR which emulates the action button
SendUp
SendDown
SendCR


Lesson four, For advanced users only. USE WITH CAUTION!
EDITING THE REGISTRY OR DELETING FILES CAN BRICK YOUR DEVICE!
ErrorLevel Disables script error messages, If your script has an error within it Mortscript will stop and display debug information, This can be disabled with this command. Meaning if one of the lines in your script has an error in it, The whole command is ignored, and the script continues, (There are exceptions to this) There are five levels, warn, error, syntax, critical (Not used) and off. They relate to what level of script errors are ignored, The lowest being warn all the way up to off which disables all errors, If you turn off the error messages then the script may stop on certain errors, Therefore it's best not to disable error messages until you are sure your script works as planned.
Errorlevel ("warn")
or
ErrorLevel ("off")

RotateScreen Rotates the display, Not all WinCE builds support screen rotation, Allowed values are 0, 90, 180, 270. 0=default, 90=Rotate 90, 180=Upside down, etc...
RotateScreen (270)

RegWriteString, RegWriteBinary, RegWriteDWord, RegWriteMultiString These commands can add or edit registry entries, This can be used to add items stored in the registry that are lost after a hard reset. String, Binary, DWord and MultiString are different types of registry entry, You really need to have an good understanding of how the registry works before attempting to modify it.
RegWriteString ("HKCU", "ControlPanel\Desktop", "Wallpaper", "\My Flash Disk\Background.bmp")
RegWriteDWord ("HKCU", "ControlPanel\Volume", "Volume", "ffffffff")
RegWriteDWord ("HKLM", "Drivers\Console", "OutputTo", "ffffffff")


RegDeleteKey Deletes registry keys as some applications won't run properly with certain entries present. The options on the end (True, True) means also delete values and subkeys if present.
RegDeleteKey ("HKLM", "System\CurrentControlSet\Control\Power\ActivityTimers", True, True)
RegDeleteKey ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts", False, False)


RegDelete Deletes registry values
RegDelete ("HKLM", System\CurrentControlSet\Control\Power\ActivityTimers\UserActivity", "TimeoutMS")

Delete Simply deletes files, Supports wildcards. (*.lnk)
Delete ("\Storage Card\UK & ROI\MapSettings.cfg")
Delete ("\Windows\Desktop\*.lnk")


Lesson five, More example scripts and further information.
Simple script that sets the volume to maximum, Plays a short sound effect and then runs Tomtom.
SetVolume (255)
PlaySound ("\Storage Card\Startup.wav")
Run ("\Storage Card\Navigator\Tomtom Navigator.exe")
Exit

Simple script to run iGO Primo on a device that looks for \Storage Card\MobileNavigator\MobileNavigator.exe after Windows CE has loaded. You would rename Script.exe/.mscr to MobileNavigator.exe/.mscr and along with Mortscript.exe place them in a folder called MobileNavigator on the root of the SD Card.
Run ("\Storage Card\Primo\iGO.exe")
Exit

Intermediate script to copy dll's from a backup folder to the windows directory before Tomtom is run.
XCopy ("\My Flash Disk\Backup\*.dll", "\Windows", TRUE, FALSE)
Run ("\Storage Card\Navigator\Tomtom Navigator.exe")
Exit

Intermediate script to briefly run the original application to set backlight brightness and some other device settings before running iGO Primo.
Run ("\My Flash Disk\navigation\mnavdce.exe")
WaitFor ("GoPal Navigator", 2)
Kill ("mnavdce.exe")
Run ("\Storage Card\Primo\iGO.exe")

Intermediate script to suspend the device when iGO Primo is running AND external power is removed.
Run ("\Storage Card\Primo\iGO.exe")
WaitFor ("NAVI",20)
While (WndExists("NAVI"))
While (ExternalPowered(True))
Sleep 1000
If (Not WndExists("NAVI"))
Exit
EndIf
EndWhile
PowerOff
EndWhile
Exit

Advanced script that stops the Debug screen on certain Navman/Mio devices from popping up when Tomtom is running.
RegWriteDWord ("HKLM", "Drivers\Console", "OutputTo", "ffffffff")
Run ("\Storage Card\Navigator\Tomtom Navigator.exe")
Exit

Advanced script that modifies some registry entries from the default settings and copies some shortcuts to the desktop, Useful for setting up WindowsCE after a hard reset.
RegWriteBinary ("HKLM", "Time", "TimeZoneInformation", "0000000047004d00540020005300740061006e0064006100720064002000540069006d00650000000000540069006d00650000000000000000000000000000000000000000000a000000050002000000000000000000000047004d00540020004400610079006c0069006700680074002000540069006d00650000000000540069006d00650000000000000000000000000000000000000000000300000005000100000000000000c4ffffff")
RegWriteDWord ("HKCU", "ControlPanel\Volume", "Volume", "ffffffff")
RegWriteString ("HKCU", "ControlPanel\Desktop", "Wallpaper", "")
XCopy("\My Flash Disk\Shortcuts\*.lnk", "\Windows\Desktop", FALSE, FALSE)
RedrawToday
Run ("\My Flash Disk\ShowTaskbar.exe")
Exit

For more information and other downloads go to the developers website -> [Please Register or Login to download file]
Or for more examples see here

If you use other commands and would like to see them included to help other members, Please either post below or PM them to me.

Fatboyfun
Currently sleeping...
Fatboyfun offline


User avatar Ex Moderator



 
Joined: Mon May 17, 2010 5:34 pm
Posts: 5782
Has thanked: 2 times
Been thanked: 408 times

Postby oodathort » Tue Mar 19, 2013 5:05 pm

Hi FBS
I have spent hours and hours trying to find a way of switching between reg keys but to no avail can you help this is the bit of mortscript I have been playing with I need to find a way of 1, selecting which key to load 2, switch between them as is at moment its one or other and have found that once you load 1 key you cannot overwite it :helpsos:

Run( "\NwdFlash\$MSD$\App\startkey.exe" )
If(WndExists("Unidentified USB Device"))
WaitForActive ("Unidentified USB Device", 5)
SendKeys( "cp210xvcp.dll" )
SendCR
Sleep(2000)
Run( "\StorageCard\Program Files\LockScreen\LockScreen.exe" )
Run("Windows\undrv.exe", "UIO1: 1000 ""Drivers\BuiltIn\NDISUIO"" Drivers\BuiltIn\ipv6hlp Drivers\BuiltIn\ZeroConfig Drivers\BuiltIn\Ethman")
Sleep(5000)
EndIf
If(WndExists("Unidentified USB Device"))
WaitForActive ("Unidentified USB Device", 10)
SendKeys( "rt2870.dll" )
SendCR
Sleep(2000)
EndIf
oodathort offline


Junior Member



 
Joined: Sat Nov 05, 2011 1:29 pm
Posts: 26
Has thanked: 0 time
Been thanked: 1 time

Postby chas521 » Tue Mar 19, 2013 8:02 pm

It's FBF BTW. Not FBS.
If it ain't broke don't fix it!
ALWAYS BACK-UP YOUR FILES/FOLDERS BEFORE MAKING EDITING CHANGES!

Please do NOT post any thanks. Simply press the hand icon with the "thumb up" which is the thank you button.
chas521 offline


User avatar Ex Moderator



 
Joined: Sat May 15, 2010 8:50 pm
Posts: 4549
Location: Long Island, NY
Has thanked: 64 times
Been thanked: 1373 times

Postby Fatboyfun » Tue Mar 19, 2013 8:21 pm

Look up Mortscript's Switch/Choice commands

Roughly like this (can't remember exact syntax)

Code: Select all
Switch(Choice("Title", "Hint,", Default option(int), "Option 1 text", "Option 2 text"))
Case (1)
#Do something
Case (2)
#Do something else
Case (0)
#Do something on cancel
EndSwitch


This will give you an on-screen menu with options.

To switch between hardware, you'll probably have to find some way of unloading the existing driver.
Currently sleeping...
Fatboyfun offline


User avatar Ex Moderator



 
Joined: Mon May 17, 2010 5:34 pm
Posts: 5782
Has thanked: 2 times
Been thanked: 408 times

Postby oodathort » Sun Apr 07, 2013 8:37 am

Hi FBF

Finally got there thanks for all your help :)


Regards

Stu
oodathort offline


Junior Member



 
Joined: Sat Nov 05, 2011 1:29 pm
Posts: 26
Has thanked: 0 time
Been thanked: 1 time

Postby Fatboyfun » Sun Apr 07, 2013 9:23 am

I'm thinking about using Hobdrive on an old device...
Currently sleeping...
Fatboyfun offline


User avatar Ex Moderator



 
Joined: Mon May 17, 2010 5:34 pm
Posts: 5782
Has thanked: 2 times
Been thanked: 408 times

Postby irinuca » Mon May 20, 2013 1:14 pm

Hi Fatboyfun .
Trying to make a script to put the device on standby when external power supply is disconnected and to wake up the device when external power supply is disconnected .
Even stop of backlight should be OK.

I have managed to build the Triggers, but I don't realize what command to do on that time.
ToggleDisplay( on? ) and SetBacklight( battery, external ) not working on PNA.
Any advice, thanks .

Code: Select all
continue=TRUE
external=1
While( continue )   
   Sleep (5000)   
   If ( ExternalPowered() AND ( external=0 ) )      
      external=1      
      command_to_wake_up
   EndIf
   If ( NOT ExternalPowered() AND ( external=1 ) )      
      external=0
      command_to_sleep
   EndIf
EndWhile


For command_to_sleep seems to work PowerOff() but I can awake the device only from 0/1 button (hardware).
I need a command_to_wake_up .
irinuca offline


Junior Member



 
Joined: Sat May 22, 2010 5:41 pm
Posts: 12
Has thanked: 2 times
Been thanked: 9 times

Postby Fatboyfun » Mon May 20, 2013 2:00 pm

The issue with pna's is the processor is halted when the device is suspended, so no mortscript command is able to wake up the device, simply because the script isn't running.

For reference ToggleDisplay (On/Off) is windows mobile only, PowerOff works though, when you see other devices waking up on AC power it's because it's configured as a hardware trigger.

There are small utilities to turn off and on the backlight, the problem here is the device is still on and will respond to screen taps even though the backlight is off, also the battery still drains quickly.
Fatboyfun offline


User avatar Ex Moderator



 
Joined: Mon May 17, 2010 5:34 pm
Posts: 5782
Has thanked: 2 times
Been thanked: 408 times

Postby meadyyyy » Tue May 21, 2013 12:09 pm

hiya fatboyfun
got an old navcam 7000 which i have been playing around with as i dont care if it bricks, any way, it doesnt connect via usb but unit still runs fine (nav software archaic), after doing some searching i discovered that it runs mainpage.exe then the main screen loads with nav button, settings, viewer, mp3. and from nav button looks for mobilenavigator on sd card (tried changing igo.exe to mobilenavigator.exe in card, it starts but units options screen re-loads over the top)
so i had a thought, your easyshell prog kills jsbhello, so tried it and changed the kill jsbhello.exe to kill mainpage.exe in the .mscr (even though it specifies not to change anything in file) and it worked and launched easyshell, from there it launched igo with no probs(not tested on road yet), tried other shells of yours but easyshell with that change was only one that worked.
so my question, i dont want to launch easyshell then igo, i lust want to laungh igo, what other changes to do i need to makes so igo runs from nav button using utilising your .mscr?
meadyyyy offline


Member



 
Joined: Sat Dec 15, 2012 12:00 pm
Posts: 109
Has thanked: 7 times
Been thanked: 5 times

Postby Fatboyfun » Tue May 21, 2013 12:54 pm

Simply create a script that kills mainpage.exe then runs iGO.
Fatboyfun offline


User avatar Ex Moderator



 
Joined: Mon May 17, 2010 5:34 pm
Posts: 5782
Has thanked: 2 times
Been thanked: 408 times

Postby meadyyyy » Sun May 26, 2013 11:01 am

ok, managed to kill mainpage.exe, then run igo (took me quite a while to do) next small problem, when exit igo it freezes on the exiting screen and goes no further, have to reset system to get menu back so i can start igo again, what do i need to insert so after igo has shut down it goes back to menu screen?
meadyyyy offline


Member



 
Joined: Sat Dec 15, 2012 12:00 pm
Posts: 109
Has thanked: 7 times
Been thanked: 5 times

Postby Fatboyfun » Sun May 26, 2013 11:18 am

Use these commands, modify the paths to suit!

Kill ("mainpage.exe")
RunWait ("\PATHTO\iGO.exe")
Run ("\PATHTO\mainpage.exe")

RunWait will start iGO and wait until it has closed before starting the shell again.
Fatboyfun offline


User avatar Ex Moderator



 
Joined: Mon May 17, 2010 5:34 pm
Posts: 5782
Has thanked: 2 times
Been thanked: 408 times

Postby meadyyyy » Sun May 26, 2013 12:43 pm

ok, solved and sorted, all runs fine
meadyyyy offline


Member



 
Joined: Sat Dec 15, 2012 12:00 pm
Posts: 109
Has thanked: 7 times
Been thanked: 5 times

Postby 968driver » Tue Jun 11, 2013 6:55 pm

Hi Fatboyfun,
your Mortscript Guide is very usefull and practical. Thanks a lot!
I have a Panasonic Strada CN-GP50N.
On a new SD card I have installed iGO primo 9.6.13, renamed the primo exe file to SDAuto.exe and the navigation works O.K., success!
When arriving at the destination I switch off the Strada (with the power switch at the left side of the Strada, the MAIN power slide switch at the bottom always staying ON).
When switching on the Strada again, it shows the last map for about 15 seconds, but the map and the user interface is frozen. Then iGO primo is starting all over again (start screen with the chrome car picture) and when the program is loaded again, then it is functional again and shows the last map.
So everytime I switch off the Strada, when switching on it reloads the primo program.
I want the Strada simply to start up with the last map, without reloading the GPS program.
I have another SD card with the ceDesktop.exe program renamed to SDAuto.exe, so I can start the Windows operation system of the Strada. But this is as far as I get.
With the original Panasonic SC card, the Strada always directly shows the last situation map without having to reload anything. This is the way I want it to work!
Do you have a suggestion? I do not need any start menu, the only application I want to run is iGO primo.

Best regards, 968driver.
968driver offline


Junior Member



 
Joined: Mon May 27, 2013 4:26 pm
Posts: 4
Has thanked: 0 time
Been thanked: 0 time

Postby Fatboyfun » Tue Jun 11, 2013 7:12 pm

What's happening here is the SD card is unmounted during suspend to save power, it takes a millisecond or two after resuming to remount the SD card, iGO can't access the card immediately and thinks there's a problem and therefore restarts, this is a hardware limitation.

However iGO can be configured to suspend the device itself, and goes into a kind of hibernate mode which gets around this problem.

On my device I configured the on screen menu key to suspend the device on long press, then when woken up it doesn't reboot, however you may need a skin (probably dimka) to enable this feature.
Fatboyfun offline


User avatar Ex Moderator



 
Joined: Mon May 17, 2010 5:34 pm
Posts: 5782
Has thanked: 2 times
Been thanked: 408 times

Next

Return to Tools & Tutorials

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest