[Windows Mobile Apps and Games] meirh18:
Battery Level check script

EDIT: Version #4

Here is my Battery Level Script. It updates only the icon(s) related to the battery (as opposed to the entire icon set, which is slow), at 10% intervals or when connected to External power. It checks on regular intervals (by default every minute).

You will need Battery Icons in a folder (../iPhoneToday/Battery) to correspond to levels 0, 10, 20 etc. and two charging icons one for full and one for not. The icons should be named battery0.png, battery10.png etc and the charging ones batteryc100.png and batteryc50.png. I use chancer63's icons, which are found here.

Note: If you are not using MioPocket, you must delete the first two lines, and manually edit the path value. If you are using MioPocket, place the script in the scripts folder as is.

Include("Variables.mscr")
Call Variables_Common
##############

#######
#BatteryLevel.mscr
########
####Credits to Holdemdog and others for the original script upon this is based
#####################
#Change "path" for your path to the "Battery" folder.
#Change "nScreen" values for a different page (-1 is the bottom bar)
#Change "nIcon" values to the number of the icon (starting at 0)

While(TRUE)

# Values:
path = ProgramsFolder\"iPhoneToday\Battery\"
bat = BatteryPercentage ()
extpow = ExternalPowered ()
extpowold = IniRead(path & "Battery.ini", "","extpowold")
batold = IniRead(path & "Battery.ini", "","batold")
batnew = Floor(Format(bat ,1)/10)*10

#Icon Position(s) - Must be set manually:
nScreen = -1
nIcon = 6
nScreen1 = 6
nIcon1 = 5

##Icon #3 for LockscreenToday:
nScreen2 = -2
nIcon2 = 1

#Compare to previous level and run ony if changed:
If(batold ne batnew OR extpow ne extpowold)

#Determine new icon:
If (extpow = 1 and bat > 50)
batpng = C100

ElseIf (extpow = 1 and bat <= 50)
batpng = C50

Else
batpng = batnew

Endif

#make sure that iPT can reload well
RegWriteDword ("HKLM","Software\iPhoneToday","reloadIcons",0)
sleep ( 1000 )

#Update Battery Icon(s):

#Icon #1

RegWriteDWord("HKLM", "\Software\iPhonetoday\icon0", "nScreen", nScreen)
RegWriteDWord("HKLM", "\Software\iPhonetoday\icon0", "nIcon", nIcon)
RegWriteString("HKLM", "\Software\iPhonetoday\icon0", "strName", "Battery")
RegWriteString("HKLM", "\Software\iPhonetoday\icon0", "strImage", path & "battery" & batpng & ".png")

#Icon #2

RegWriteDWord("HKLM", "\Software\iPhonetoday\icon1", "nScreen", nScreen1)
RegWriteDWord("HKLM", "\Software\iPhonetoday\icon1", "nIcon", nIcon1)
RegWriteString("HKLM", "\Software\iPhonetoday\icon1", "strName", "Battery")
RegWriteString("HKLM", "\Software\iPhonetoday\icon1", "strImage", path & "battery" & batpng & ".png")

#Icon #3 for LockscreenToday
If(ProcExists("LockscreenToday.exe"))
RegWriteDWord("HKLM", "\Software\iPhonetoday\icon2", "nScreen", nScreen2)
RegWriteDWord("HKLM", "\Software\iPhonetoday\icon2", "nIcon", nIcon2)
RegWriteString("HKLM", "\Software\iPhonetoday\icon2", "strName", "")
RegWriteString("HKLM", "\Software\iPhonetoday\icon2", "strImage", path & "battery" & batpng & ".png")
EndIf

#Reload:
RegWriteDWord("HKLM", "\Software\iPhonetoday", "reloadIcon", 1)

#Record current setting for comparison
IniWrite(path & "Battery.ini", "","batold", batnew)
IniWrite(path & "Battery.ini", "","extpowold", extpow)

EndIf

#Repeat after 1 minute (60,000 milliseconds)
Sleep(6000)
EndWhile