一、认识rlToday
rlToday是一个今日插件,但它本身什么也没有提供,利用它,你却又能在今日桌面上显示任何你想要显示的东西,它实际上应该是一个今日插件的平台。它的使用目标是以功能为主,而不是一个单纯的桌面美化软件。它能调用MortScript,因此它的功能可以得到很大程度的提升,在这个平台上,只要你能想到,就想办法去做吧,就怕你想不到。它与其它有类似功能的软件相比有几点很大的不同。一是调用方式不同:安装完成后,你只要在系统的今日选项卡里钩选一下就行了,与其他今日插件是同等待遇,不想用了也是去今日选项卡里面取消选择就行,与其它今日插件一样,不用的时候只占用很小的内存。其他软件基本上都是以外壳的形式存在的,系统运行以后要调用,没有退出以前系统是被这些外壳程序控制的,需要占用比较大的内存。二是运行方式不同:比如像spb shell、WAD、PPX一些桌面美化软件,是一种外壳工具,他把系统本身包裹起来,穿上一件漂亮的外衣,你的美化操作都是针对外壳的,这些外壳有虚拟页的功能,这些虚拟页是同时存在的,你可以随意来往于各个不同的虚拟页,很方便,但要以牺牲内存为代价。rlToday不同的是,它没有建立虚拟页,只是将桌面做成了很多不同的表现形式,想用哪一个就调用那一个,从使用者的角度看,和其他虚拟页的感觉是一样的,这正是它的聪明之处,因为只要你的存储空间允许,它可以设置任意数量的桌面表现形式,而不会增加使用内存的数量。三是操作方式不同:rlToday很简单,程序只有300K,实现复杂的功能要和MortScript配合使用,它给用户提供了一个可以编程的机会,用户可以发挥自己的想象力去完成它本身没有提供的功能,而其他外壳工具往往在这一点上把用户限制了,正是这一点是rlToday的生命力的所在。 二、软件的安装 第一步,安装rlToday和MortScript rlToday和MortScript分别是二个CAB文件,拷贝到PPC上运行,不需要进行任何设置,在PPC的Program Files夹下产生MortScript和rlToday二个文件夹。
MortScript文件夹可以不去管它,rlToday文件夹下会有一些目录和文件,每一个目录都是一页皮肤文件(注意是一页),这些目录和文件会有不同。还有一些后缀为mscr的脚本文件(脚本文件后面会提到,是我们的重点),一个dll文件和一个ini文件,rlToday.ini是他的配置文件,可以用记事本打开来修改。 ![]() ![]() 第二步,配置rlToday 在系统的今日设置里选择项目,然后选中rlToday,关闭其他今日插件。 ![]() ![]() 返回桌面,会出现rlToday.ini里面配置的桌面,如果不是也没有关系,操作都是一样的。 (图4) ![]() ![]() 在桌面上插件的显示区域内常按屏幕,会弹出一个菜单,选择options进入选择页面。 ![]() ![]() ![]() ![]() 在Skin下拉菜单里选择你需要的皮肤,一般皮肤名称前部分一样的时代表同一款皮肤,序号不同代表不同页面,选哪一个都可以,因为它们是互相调用的。 Apps选项卡里面可以定义你想要在桌面上显示的快捷程序,只要Add就可以了。 ![]() ![]() 返回桌面,OK 三、编一个简单的小插件 先编一个非常常见的小插件,一个模拟时钟和日历, ![]() ![]() 第一步,建立一个目录,名称随便,这里就叫时钟。 第二步,准备素材。这里只需要一个钟面,可以自己画一个,也可以到网上去搜一下,大把。最好是png格式,因为这样就可以做成透明的了。在这里用了一个图片sys.png。放在目录中 (图sys.png) ![]() ![]() 第三步,用记事本建立一个文本文件,名字为skin,后缀必须是XML,然后输入以下文本内容: <?xml version="1.0" encoding="gb2312"?> <today height="100" refresh="100"> <AnalogClock timezone="0" x="50" y="2" clockface="sys.png" /> <Date x="170" y="4" format="yyyy MMM" Alignment="Center" color="RGB(215, 215, 215)"> <Font size="12" weight="normal" font="Tahoma" /> </Date> <Date x="170" y="20" format="d" Alignment="Center" color="RGB(255, 255, 255)"> <Font size="24" weight="normal" font="Tahoma" /> </Date> <Date x="170" y="50" format="ddd" Alignment="Center" color="RGB(230, 230, 230)"> <Font size="12" weight="normal" font="Tahoma" /> </Date> </today> 其中,第一行不用管它,照写就行。第二行,today height="100"代表你要做的插件在今日屏幕上需要占用的高度为100个像素。第三行,定义了一个时钟,这是rlToday内部提供的,timezone="0"是时区,在rlToday设置里有一个Time选项,把除China以外的都去掉,这个参数就不用动了。X和y分别代表屏幕坐标,表示你要将时钟图片放在那里,clockface="sys.png"是表示你要用的钟面的图片。第四行到第十二行定义了一个日历,可以定义的有格式、位置、颜色、字体、字体大小等项目。 第四步,写完以后存盘,然后将整个目录拷贝到PPC你安装rlToday的目录下,按照软件安装节里的第二步操作,选取你刚做好的时钟作为皮肤。 ![]() ![]() 欣赏一下你自己的大作吧,千好万好不如自己的好。 四、增加功能 1、直接调用定义好的应用程序 刚才做的插件只能显示一个时钟和日历,没有任何动作,现在加上一些命令,让他能够做一些简单动作。 <Date x="170" y="4" format="yyyy MMM" Alignment="Center" color="RGB(215, 215, 215)"> <Font size="9" weight="normal" font="Tahoma" /> <OnClick File="\Windows\Calendar.exe" /> </Date> 我们在原来显示年月的语句里加了一条命令<OnClick File="\Windows\Calendar.exe" />,它的含义是在屏幕上点击显示出来的年月的位置,会触发一条命令,去执行Windows目录下的Calendar.exe文件,这是系统自带的日历。保存好,点击屏幕出现弹出菜单,这次选择Reload Skin,它会重新装入皮肤文件,然后点一下屏幕上显示年月的地方,看看发生了什么。 这时最直接的程序调用,你可以用文字、图片来作为点击的目标,实现程序调用。 这是用图片作为点击目标的语句: <Image x="0" y="101" source="1.png"> <OnClick File="\Windows\fexplore.exe" /> </Image> <Image x="40" y="101" source="1.png"> <OnClick File="\Program Files\WM5torage\WM5torage.exe" /> </Image> 二个按钮图片分别调用Windows目录下的资源管理器和Program Files夹下的U盘程序。 这是用图片作为点击目标的语句: <Text text="手机短信" x="24" y="20" alignment="Center" color="RGB(185, 185, 185)" > <Font size="12" weight="bold" font="Tahoma" /> <OnClick File="\Windows\tmail.exe" /> </Text> 2、在桌面显示快捷程序图标 刚才的调用是固定的,当程序运行以后是不能改变的,rlToday提供了可以自定义桌面快捷程序的能力,在设置里可以自由添加和删除,如果要显示出这一部分快捷方式,就要加上以下语句: <Application x="5" y="70" appnumber="0" /> <Application x="45" y="70" appnumber="1" /> <Application x="85" y="70" appnumber="2" /> <Application x="125" y="70" appnumber="3" /> <Application x="165" y="70" appnumber="4" /> <Application x="205" y="70" appnumber="5" /> 这里定义了五个快捷方式,也就是说做多能显示五个,你可以加上更多的语句,显示更多的快捷方式,语句后面的序号一定不要重复。 3、页面调用 PPC的桌面很小,而我们想要显示的东西很多,都挤在一起不仅难看也不方便,于是出现了虚拟桌面,rlToday没有使用虚拟桌面,而是采用了调用一个全新的页面来显示不同的内容,需要的时候就调用,而不是切换。好处就是节省内存。下面是一段调用新页面的语句: <Image x="0" y="1" source="1.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H0"'/> </Image> 这是通过点击图片来进行调用的,但是在OnClick语句中,并不是上一节里面介绍的直接调用皮肤文件,而是通过MortScript.exe文件执行了一条命令,它有二个参数,第一个是脚本文件的路径和名称,第二个是"skin=H0",这是通过调用一个叫做ChangeVista.mscr的脚本文件去打开一个皮肤文件,我们看一下ChangeVista.mscr文件中有什么内容, installdir=RegRead("HKLM", "\SOFTWARE\Apps\rotlaus Software rlToday\", "InstallDir") inifile=installdir\"rlToday.ini" Switch(skin) Case("H0") IniWrite(inifile, "General", "Skinfile", "Vista_H0") Case("H1") IniWrite(inifile, "General", "Skinfile", "Vista_H1") Case("H2") IniWrite(inifile, "General", "Skinfile", "Vista_H2") Case("H3") IniWrite(inifile, "General", "Skinfile", "Vista_H3") Case("H4") IniWrite(inifile, "General", "Skinfile", "Vista_H4") Case("H5") IniWrite(inifile, "General", "Skinfile", "Vista_H5") Case("H6") IniWrite(inifile, "General", "Skinfile", "Vista_H6") Case("H7") IniWrite(inifile, "General", "Skinfile", "Vista_H7") EndSwitch RedrawToday 脚本首先通过读取注册表获得rlToday的安装路径,调用配置文件,然后是一组Case语句,用来选择需要调用的皮肤文件,每个皮肤文件都是和一个相应的目录对应的。你可以随意改动文件夹的名称,只要在这个文件里做相应改动就行,而不用去逐个修改皮肤文件。 如果做一排按键,分别调用不同的页面,它的程序是这样的: <Image x="0" y="1" source="1.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H0"'/> </Image> <Image x="40" y="1" source="1.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H1"'/> </Image> <Image x="80" y="1" source="1.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H2"'/> </Image> <Image x="120" y="1" source="1.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H3"'/> </Image> <Image x="160" y="1" source="1.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H4"'/> </Image> <Image x="200" y="1" source="1.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H5"'/> </Image> 4、管理其他插件 桌面应用最重要的应该是能够对插件进行管理,做不到这一点,桌面很难清爽的了,rlToday是通过对注册表的操作来实现管理的。在刚才调用页面的程序的基础上,增加了二条语句: <Image x="40" y="1" source="1.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\Set4.mscr" "V=0"'/> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\Set3.mscr" "V=1"'/> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H1"'/> </Image> 可以看得出来,增加的语句结构与刚才的一样,只不过调用的脚本文件不同而已,秘密还是在脚本文件里,我们看一下Set4.mscr和Set3.mscr这二个文件的内容: Set4.mscr文件中只有一行语句 RegWriteDWord("HKLM","SOFTWARE\Microsoft\Today\Items\""Spb Diary""\","Enabled",V ) 这是对注册表的写操作,这是路径:SOFTWARE\Microsoft\Today\Items\""Spb Diary""\,这是键值:Enabled,这是参数:V,V=1是激活插件,否则反之。 上面的调用语句中V=0,就是要关闭这个插件,通过路径我们可以看出这个插件是"Spb Diary"。 Set3.mscr文件中有二条语句, RegWriteDWord("HKLM","SOFTWARE\Microsoft\Today\Items\""Spb Weather""\","Enabled",V ) RegWriteDWord("HKLM","SOFTWARE\Microsoft\Today\Items\""GPRS Monitor""\","Enabled",V ) 看得出来分别是"Spb Weather"和"GPRS Monitor"二个插件,在上面的调用语句中给这个脚本文件的参数是V=1,也就是说要激活"Spb Weather"和"GPRS Monitor"这二个插件。当按下这个按钮就是要关闭"Spb Diary"这个插件,同时激活"Spb Weather"和"GPRS Monitor"二个插件,然后调用一个新的皮肤文件。 这时执行以后的屏幕状态: ![]() ![]() 要想了解已经安装的今日插件,只要看一下今日的设置就行了。 ![]() ![]() 但是有一点需要注意,插件的名称有的带引号,有的不带,不要弄错了,这一点在今日设置里看不出来,可以通过SKTools软件查询一下: ![]() ![]() ![]() ![]() 注意在这里可以看出"GPRS Monitor"是带引号的。 5、最小化 在很多情况下,我们只想让桌面干干净净,除了其他插件要隐藏以外,rlToday自己也要最小化,要实现这一点非常容易,只要将插件高度定义的小一些就行了。 <today height="15" refresh="1000"> 这个插件的高度只有15个像素。 ![]() ![]() 6、隐藏 如果把插件的高度定义的更小一些是否可以隐藏呢,当然可以,不过隐藏的同时也会给你带来更多的麻烦,因为你再也找不着这个插件了,实现隐藏,当然还要让它能够随时调回来,我是用另外的方法实现的。 <?xml version="1.0" encoding="gb2312"?> <today height="245" refresh="100"> <Image x="0" y="0" source="H5.png"> <OnClick File="\Program Files\MortScript\MortScript.exe" command='"\Program Files\rlToday\ChangeVista.mscr" "skin=H0"'/> </Image> </today> H5.png是一张全屏幕尺寸的空白透明的图片,将插件的尺寸定到全屏,因为是透明图片,运行后桌面完全看不到插件,但是点击屏幕任何地方都能将插件重新找回来。 ![]() ![]() 五、使用MortScript经常会用到的命令与操作: 字符串操作 ----------------- string = Split( <string>,<seperator>,<trim?>,<variable>{,<variable>} ) (if only one variable, it's used as array) string = Part( <string>,<seperator>,<index>[,<trim?>] ) int= Length( <string> ) string = SubStr( <string>,<start>,<length> ) int= Find( <string>,<search string> ) string = Replace( <string>,<search string>,<new string> ) int= ReverseFind( <string>,<search character> ) string = ToUpper( <string> ) string = ToLower( <string> ) 程序运行 --------- Run( <application> [, <parameter>] ) RunWait( <application> [, <parameter>] ) New( <menu entry> ) (Windows Mobile only) RunAt( <unix timestamp>, <application> [, <parameter>] ) RunAt( <year>, <month>, <day>, <hour>, <minute>, <application> [, <parameter>] ) RunOnPowerOn( <application> [, <parameter>] ) RemoveNotifications( <application> [, <parameter>] ) 窗口控制 -------------- Show( <window title> ) Minimize( <window title> ) Close( <window title> ) string = ActiveWindow() bool= WndActive( <window title> ) bool= WndExists( <window title> ) WaitFor( <window title>,<seconds> ) WaitForActive( <window title>,<seconds> ) string = WindowText( <x>, <y> ) GetWindowPos( <window title>, <left>, <top>, <right>, <bottom> ) int= WndLeft( <window title> ) int= WndRight( <window title> ) int= WndTop( <window title> ) int= WndBottom( <window title> ) SendSpecial( <key> [, <state> ) Available keys (quoted string): Alt, Ctrl, Shift, CR, Win, Context, Tab, ESC, Space, Up, Down, Left, Right, Home, End, PageUp, PageDown, Delete, Backspace, Insert, Snapshot, F1 - F12, LeftSoft, RightSoft Availabe states (quoted string): up, down - omit parameter for short press SendOK [ ( <window title> ) ] SendCancel [ ( <window title> ) ] SendYes [ ( <window title> ) ] SendNo [ ( <window title> ) ] 鼠标事件 ----------------------------- MouseClick( [<window title>,]<x>,<y> ) MouseDblClick( [<window title>,]<x>,<y> ) MouseDown( [<window title>,]<x>,<y> ) MouseUp( [<window title>,]<x>,<y> ) 延时 ------- Sleep( <milliseconds> ) SleepMessage( <seconds>,<message>[,<title>[,<allowOK>[,<condition]]] ) WaitFor( <window title>,<seconds> ) WaitForActive( <window title>,<seconds> ) 时间 ---- int= Time() (Unix timestamp) string = FormatTime( <format> [, <timestamp> ] ) (formatted) GetTime( <variable>,<variable>,<variable> ) (hour, minute, seconds) GetTime( <variable>,<variable>,<variable>,<variable>,<variable>,<variable> ) (hour, minute, seconds, day, month, year) 文件操作 -------------------------------- Copy( <source file>,<target file>[,<overwrite?>] ) XCopy( <source files>,<target directory>[,<overwrite?>[,<recursive?>]] ) Rename( <source file>,<target file>[,<overwrite?>] ) Move( <source files>,<target directory>[,<overwrite?>[,<recursive?>]] ) Delete( <files> ) DelTree( <files> ) CreateShortcut( <shortcut file>,<target file>[,<overwrite?>] ) 读写文本文件 ------------------------- string = IniRead( <file/url>,<section>,<key> ) IniWrite( <file>,<section>,<key>,<value> ) string = ReadFile( <file/url> ) WriteFile( <file>,<contents>,<append?> ) 文件系统信息 ------------------------ bool= FileExists( <file> ) bool= DirExists( <directory> ) int= FileCreateTime( <file> ) int= FileModifyTime( <file> ) int= FileSize( <file> ) int= FreeDiskSpace( <directory> ) bool= FileAttribute( <file>, <attribute> ) bool= SetFileAttribute( <file>, <attribute>, <set?> ) Allowed values for Attribute? directory (cannot be set), hidden, readonly, system, archive SetFileAttribs( <file>,<readonly>[,<hidden>[,<archive>]] ) (1=set,0=remove,""/omit=keep) string = FileVersion( <file> ) GetVersion( <file>,<variable>,<variable>,<variable>,<variable> ) 目录操作 -------------------- MkDir( <directory> ) RmDir( <directory> ) ChDir( <directory> ) PC version only! SystemPath( <path> ) valid values for path: ProgramsMenu, StartMenu, Startup, Documents, ProgramFiles, ScriptExe, ScriptPath, ScriptName, ScriptExt 注册表操作 -------- RegWriteString( <root>,<path>,<key>,<value> ) RegWriteDWord( <root>,<path>,<key>,<value> ) RegWriteBinary( <root>,<path>,<key>,<value> ) value = RegRead( <root>,<path>,<key> ) RegDelete( <root>,<path>,<key> ) RegDeleteKey( <root>,<path>,<values?>,<recursive?> ) bool= RegKeyExists( <root>,<path> ) bool= RegValueExists( <root>,<path>,<value> ) "root" values: HKCU (HKEY_CURRENT_USER), HKLM (HKEY_LOCAL_MACHINE), HKCR (HKEY_CLASSES_ROOT), HKUS (HKEY_USERS) Binary values are handled as strings whith the hex dump, e.g. "01020A". 对话框 ------ string = Input( <message> [,<title> [,<numeric?> [, <multiline?> [, <default> ]]]] ) Message( <text>[,<title>] ) BigMessage( <text>[,<title>] ) SleepMessage( <seconds>,<message>[,<title>[,<allowOK>[,<condition]]] ) int= Question( <message> [,<title> [,<type>]] ) (Type=OkCancel,YesNo,YesNoCancel; Yes/OK=1,No=0,Cancel=2) int= Choice( <title>,<message>,<default>,<timeout>,<array> ) (if only one text is given, it's assumed to be a array variable) int= Choice( <title>,<message>,<default>,<timeout>,<text1>,<text2>{,<text3>} ) (if only one text is given, it's assumed to be a array variable) string = SelectDirectory( <title>, <message> [,<default>] ) string = SelectFile( <title>, <save?> [, <filter> [, <info> [,<default>]]] ) 进程管理 --------- bool= ProcExists( <process name> ) bool= ScriptProcExists( <script name> ) string = ActiveProcess() Kill( <process name> ) KillScript( <script name> ) 信号 ------- SetVolume( <value> ) (Windows Mobile only) PlaySound( <wav file> ) Vibrate( <milliseconds> ) 屏幕显示 -------------- int= ColorAt( <x>,<y> ) int= RGB( <red>,<green>,<blue> ) int= Red( <color> ) int= Green( <color> ) int= Blue( <color> ) Rotate( 0|90|180|270 ) (only Windows Mobile 2003 SE or higher) SetBacklight( <battery>,<external> ) (PPC only) ToggleDisplay( <on/off> ) (PPC only) bool= Screen( "landscape"|"portrait"|"square"|"vga"|"qvga" ) RedrawToday ShowWaitCursor HideWaitCursor 剪贴板 --------- SetClipText( <text> ) string = GetClipText() 内存 ------ int= FreeMemory() int= TotalMemory() 电力 ------ bool= ExternalPowered() int= BatteryPercentage() PowerOff IdleTimerReset (Windows Mobile only) 系统 ------ MortScriptType() value = SystemVersion( [<element>] ) element: "major", "minor", "build", "platform", omit for major.minor.build Reset (Windows Mobile only) 程序流程的控制结构 ================== If ( <condition> ) { ElseIf ( <condition> ) } [ Else ] EndIf Choice ( <title>,<message>,<text1>[,<text2>,...] ) | ChoiceDefault ( <title>,<message>,<default>,<timeout>,<text1>,[<text2>,...] ) Case ( <index>[,<index>,...] ) EndChoice (if only one text is given, it's assumed to be a array variable) Switch ( <value> ) Case ( <index>[,<index>,...] ) EndSwitch While ( <condition> ) EndWhile Repeat ( <count> ) EndRepeat ForEach <variable> in values ( <value>{,<value>} ) | ForEach <variable>[,<variable>] in array ( <array variable> ) | ForEach <variable> in split ( <string>,<seperator>,<trim?> ) | ForEach <variable> in charsOf ( <string>,<seperator> ) | ForEach <variable> in iniSections ( <file/url> ) | ForEach <keyVariable>,<valueVariable> in iniKeys ( <file/url>,<section> ) | ForEach <variable> in regSubkeys ( <root>, <key> ) | ForEach <valueVariable>,<dataVariable> in regValues ( <root>,<key> ) | ForEach <variable> in files ( <file/url>,<files> ) | ForEach <variable> in directories ( <file/url>,<directories> ) EndForEach Call( <subroutine> { , <parameter> } ) CallFunction( <subroutine>, <result variable>, { , <parameter> } ) (mind to use quotes for the subroutine name, e.g. "Call ("MySubRoutine")" or use the old syntax without parentheses, like "Call MySubRoutine"). CallScript( <mortscript file (full path!)> { , <parameter> } ) CallScriptFunction( <mortscript file>, <result variable>, { , <parameter> } ) Return( <value> ) (only sets result for Call(Script)Function, does not leave Sub/Script!) Sub <subroutine> EndSub Exit |
|