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