[Windows Mobile Development and Hacking General] MichelDiamond:
#2 Library

Fine - from Post #1 you know the directory structure - now let's go to our example - the WeatherBackgroundChanger.

You will see, how powerful and easy it is, to make something like such a Background-Changer

The Library-Script should look at the current weather and because of this changes your complete titanium Background. If it's sunny, then you will get a picture of a Sun as Background... and so on (Screenshots in #3)

Have in mind - it's a Library-Script - so it will be stored direct in the "JMLLibrary"-Directory

I've chosen the name (it's free how you name it - no convention, but I recommend to start at least with JMLLib_...) : JMLLib_weatherbackgroundchanger.mscr

The graphics are stored in /<Program Files>/JMLLibrary/Graphics/common/weatherbackgroundchanger

It's not necessary to put them in essential - if the graphics wouldn't be found, than only the copy wouldn't work and the current Background would remain. I called the pictures "sun.jpg" "flash.jpg"... and so on.

They are VGA-Resoltion at the moment - but you can change them to the size, which you need - and also: everybody likes other pictures... feel free to change them. But never change the filenames :)

OK - and here's the code - all the code above the ################# you mustn't touch - it's always the same - it only provides you the pathes.

As Developer you only have to make the Part under this ##########

- and withoutout comments... it would be very short and you see - it's easy:

# Made by MichelDiamond, 27.07.09
# Version 1.0
# Description:
# Changes the Background of Titanium according to the Weather-State of JMLToday - VGA

# following pathes are still the same - no need to change it if you make your own Library-Script - each script in /<Program-Path</JMLLibrary
LibraryPath = SystemPath( "ScriptPath" )
CommonGraphicPath = RegRead ("HKLM", "Software\Microsoft\CHome\JMLToday","CommonGraphicPath")
EssentialGraphicPath = LibraryPath&"\Graphics\essential"

# no update during phoning
If (RegRead("HKLM","System\State\Phone","Status") AND 537067520)
exit
EndIf

############################## Now we can start with our own script

# Weather-Icon is available?
if (RegValueExists("HKLM", "Software\Microsoft\CHome\JMLToday\Page1","Icon") = FALSE)
exit
endif

# Get WeatherIcon
weathericon = RegRead("HKLM", "Software\Microsoft\CHome\JMLToday\Page1","Icon")

# Get number as String ( Icon= <jmlpath>\meteo\<number>.png )
weatherpng = Part(weathericon , "\", -1)
weatherstring = Part(weatherpng,".",1)

# Weather -> Backgroundpic (if nothing is found it's sunny)
picname="sun.jpg"
Switch( weatherstring )
Case( 27,29,31,33,45,46 )
picname="moon.jpg"
Case( 6,8,9,13,14,18,19,21,22,26,39 )
picname="cloud.jpg"
Case( 1,2,10,11,12 )
picname="rain.jpg"
Case( 3,4,12,17,35,38,47 )
picname="flash.jpg"
Case( 5,7,15,16,25,40,41,42,43 )
picname="snow.jpg"
EndSwitch

# Copy this pic from ...graphics\common\weatherbackgroundchanger to Wallpaper in Windows-Directory
# The Wallpaper's name is e.g. Stwater_480_640.jpg (VGA) - other resolutions corresponding
# you can find the Wallpaper in Registry-Key "HKCU\Software\Microsoft\Today\Wall
# For example with VGA the content of this key is "\windows\stwater_480_640.jpg"
source=CommonGraphicPath&"\weatherbackgroundchanger\"&picname
dest=RegRead("HKCU", "Software\Microsoft\Today","wall")
Copy(source,dest,TRUE)

# Titanium Refresh must be made by the calling script
exit

I think the comments are good to understand, what this script does.

But only remind, if you also make an AddOn with the Library: You can use each Registry-String, each file... you can manipulate all Registry-String... and so there are soooooooooo much possibilities for AddOns.

OK - in Post #3 will be the both Skins, which uses this Library-Element and they change the Background according to the weather.

Here is the download for the Library - it's international format and will install in the correct directories (But don't forget... you need a skin, which uses it - but meanwhile you can change the Graphics to your favorite Graphics and Resolution)

The current download of JMLLibrary is to find:

*here*

.

.