View Single Post
Old 12/27/2006, 01:29 AM   #1 (permalink)
hannip
Member
 
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 93 Times in 33 Posts
Default Fun with MortScript

I'm surprised that more people don't use MortScript. It is a very useful scripting language for mobile devices. It is freeware and can handle some pretty complex tasks with a few lines of code.

Case in point. I was able to write a simple script to monitor notifications and turn on the led blink when any are active.

MortScript can read and write to the registry, execute programs and subroutines and functions, send keystrokes and mouseclicks to applications, perform file manipulation and a lot more.

There is a new version 4.0 available here.
http://www.sto-helit.de/index.php?mo...st&category=17

Documentations is here.
http://www.sto-helit.de/downloads/po...4.0-Manual.pdf


Example:
Code:
#
# NLED.mscr - Monitors notifications and turns on and off the notification LED accordingly.
#

# check dependencies
If ( NOT FileExists( "\Windows\LEDUp.exe" ) )
   Message ( "Installation of LEDUp.exe is required! Exiting...", "NLED script" )
   Exit
EndIf

# initialize variables
LedOn = FALSE
Notify = FALSE

# start notification check loop
While ( 1 )

# check the registry for any notifications
   Notify = RegValueExists( "HKLM", "System\State\Shell\Notifications\Active", "CLSID" )

# turn on the led if any notifications are pending. Keep turning on each iteration since
# the OS turns it off whenever there is a new notification.
   If ( Notify )
      RunWait( "\Windows\LEDUp.exe", "0 1" )
      LedOn = TRUE
   EndIf

# turn off the led if no notifications are pending
   If ( LedOn && NOT Notify )
      RunWait( "\Windows\LEDUp.exe", "0 0" )
      LedOn = FALSE
   EndIf

# wait 5 seconds
   Sleep( 5000 )

EndWhile

People should post useful scripts they write to this thread for others to use. Attached is the above code zipped up. It requires installation of LEDUp.exe also attached. Install MortScript, LEDUp and copy the script to your device. Paste a shortcut of the script to \Windows\Startup to have it start at boot if it works for you.

Edit: Changed sleep to 5 seconds to activate the led before the keyguard puts the device to sleep when locked.
Attached Files
File Type: zip LEDUp.zip (4.4 KB, 1055 views)
File Type: zip NLED.zip (595 Bytes, 813 views)

Last edited by hannip; 03/15/2007 at 01:17 AM. Reason: point to released MortScript 4.0
hannip is offline   Reply With Quote