MortScript使用教程Word文档下载推荐.docx

上传人:b****5 文档编号:16192878 上传时间:2022-11-21 格式:DOCX 页数:24 大小:26.89KB
下载 相关 举报
MortScript使用教程Word文档下载推荐.docx_第1页
第1页 / 共24页
MortScript使用教程Word文档下载推荐.docx_第2页
第2页 / 共24页
MortScript使用教程Word文档下载推荐.docx_第3页
第3页 / 共24页
MortScript使用教程Word文档下载推荐.docx_第4页
第4页 / 共24页
MortScript使用教程Word文档下载推荐.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

MortScript使用教程Word文档下载推荐.docx

《MortScript使用教程Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《MortScript使用教程Word文档下载推荐.docx(24页珍藏版)》请在冰豆网上搜索。

MortScript使用教程Word文档下载推荐.docx

除PC系统外适用,用于CAB包安装、卸载信息记录。

此二个DLL文件,如不使用上述二个功能时,可以不要。

另:

适用CE系统的版本,基本兼容适用WM系统。

Autorun.exe:

运行该程序,执行同名.mscr脚本,该程序可改名。

不改名可放在2577或0文件夹,而得以在拨、插储存卡时支持自动运行(插

卡时执行autorun.mscr,拨卡时执行autoexit.mscr,老程序则为:

autorun.mortrun和

autoexit.mortrun),当然,并不是所有设备都支持该

功能。

且该程序需要MortScript.exe主程序支持。

五、一个PPC独有的可选参数:

/wait=n

n为一个以秒为单位的数字,除此外的所有类似于此的表达式均为变量的定义表达,当然,所有其他参数也不会以/或-开始。

该功能用于如关

联了PPC按键,但在PPC唤醒时段不能执行脚本时候的延时辅助。

不过,MortScript已默认5秒延时。

六、帮助手册PDF里的命令语法样式说明:

粗体字:

命令、函数名、关键字。

斜体字:

变量,常用表达式。

[]:

中括号为可选项(即可省略项)。

{}:

花括号为可多选项或省略项。

():

分组,经常用|符来列出可选项。

注:

函数不能省略括号,命令可以省略。

如:

message("

你好!

"

)和message"

X|Y|Z:

必选其中一个选项,常为定值选择。

七、常用语法:

关键字:

XXX"

引号在字符串里的引用,需要双层使用。

^CR^:

回车;

^LF^:

换行;

^NL^:

^TAB^:

制表符。

(^CR^^LF^=^NL^)

字符串表达式:

value=Eval(string)

常数:

3.1415926

变量:

X=表达式

Set(variable,expression)

变量名由:

字母、数字(不能以数字打头)、下划线组成,且不区分大小写。

X+=1相当于x=x+1;

类似的双目运算符还有:

-=、*=、/=、&

=、\=。

预定义变量:

TRUE,ON,YES:

初始值为1;

FALSE,OFF,NO:

初始值为0;

CANCEL:

初始值为2;

PI:

3.84626433832759

SQRT2:

1.4......

PHI:

1.6......

EULER:

2.7......

全局变量:

Global(variable{,variable})

局部变量:

Local([variable{,variable}])

数组array[]:

实质一种特殊类型的变量。

数组名和元素名也是不区别大小写的。

Clear(variable)

检验变量:

bool=IsEmpty(variable)

返回变量类型:

int=VarType(variable)

返回值列表:

var_empty;

var_int;

var_float;

var_string;

var_array;

var_window。

函数:

函数名(参数)

运算符:

(按由高到低优先级列表)

()

NOT

^

*,/,MOD

+,-

&

\

>

>

=,<

<

=,=,<

gt,ge,lt,le,eq,ne

condition?

true:

false

AND,&

OR,||

八、流程控制语句:

1、条件判断控制:

If(wndExists("

Word"

))

EndIf

While(X<

5)

EndWhile

If(表达式)

{语句}

{ElseIf(表达式)

{语句}}

[Else

{语句}]

2、多重分支控制:

Switch(表达式)

Case(参数{,参数})

{指令}

{Case(参数{,参数})

{指令}}

{Default

EndSwitch

Choice(title,hint,value,value{,value})

Choice(title,hint,array)

ChoiceDefault(title,hint,default,timeout,value,value{,value}))

Case(value{,value})

{instructions}

{Case(value{,value})

{instructions}}

EndChoice

示例:

choice("

Test"

"

selectanumber"

one"

two"

three"

case

(1)

case(2,3)

twoorthree"

case(3)

case(0)

cancel"

exit

endchoice

3、条件循环控制:

while(条件)

{表达式}

endwhile

4、迭代循环:

ForEachvariable{,variable}intype(parameter{,parameter}){instructions}

endforeach

ForEachvariableinvalues(value{,value})

ForEachvariableinarray(arrayvariable)

ForEachkey,valueinarray(arrayvariable)

ForEachvariableinsplit(string,separator,trim?

ForEachvariableinCharsof(string)

ForEachvariableininiSections(filename[,codepage])ForEachkey,valueininiKeys(filename,section[,codepage])ForEachvariableinregSubkeys(root,key)

ForEachvalue,dateinregValues(root,key)

ForEachvariableinfiles(searchexpression)

ForEachvariableindirectories(searchexpression)

5、常数循环:

Repeat(count)

EndRepeat

6、FOR循环:

Forvariable=starttoend[stepstep]

Next

7、中断和继续:

中断:

Break[(structuretype)]

继续:

Continue[(structuretype)]

8、错误处理:

Try

instructions

{Catch

instructions}

EndTry

错误提示等级:

ErrorLevel(errorlevel)

off:

关闭出错提示;

critical:

特殊提示;

syntax:

语法错误提示(参数错误;

无效命令;

函数名);

error:

其他错误;

warn:

文件或文件夹

的移动,复制,重命名出错。

9、子程序及函数的调用:

Subsubroutine[(parameter{,parameter})]

EndSub

内部:

Call(subroutine{,parameter})

CallFunction(subroutine,variable{,parameter})

外部:

CallScript(MortScriptfile{,parameter})

CallScriptFunction(MortScriptfile,variable{,parameter})

10、包含子程序的其他文件命令:

Include(file)

11、参数返回:

Return(value)

12、子程序的退出:

ExitSub[(value)]

九、字符串操作:

int=Length(string)

返回字符串字数。

(含字符串里的空格)

string=SubStr(string,从左往右第几位[,截取几个])

字符串截取。

截取长度省略或超长,则截取至完。

截取长度短于字串数,则返回空字符串。

位数为负时,则反向截取。

string=CharAt(string,位置)

返回字符串指定位置的字符。

string=Part(string,separator,index[,trim?

])

返回字符串指定分隔符部分,并修整移除空格旁的部分。

index可为负。

string=Find(stringtocheck,stringtosearch[,start])

字符串包含查找。

返回第二个字符串,包含于第一个字符串的位置。

start为位置参数。

查找区分大小写。

int=ReverseFind(string,character)

返回字符所在字符串位置的倒数位置。

string=Replace(source,old,new)

返回被新替换旧字串后的目标字符串。

string=ToUpper(string)

string=ToLower(string)

大小写转换。

string=UcChar(value)

int=UcValue(string)

字符和Unicode值转换。

string=FilePath(filewithpath)

string=FileBase(filewithpath)

string=FileExt(filewithpath)

文件路径、文件名、文件扩展名的截取。

十、数学函数:

string=Format(value,decimals)

返回值保留小数点后几位,由decimals指定倍数。

string=NumberToHex(intvalue)

int=HexToNumber(string)

字符的十六进制转换。

int/float=Round(value[,precision])

int/float=Floor(value[,precision])

int/float=Ceil(value[,precision])

四舍五入;

四舍五入并取整;

取整;

int=Rand(max)

float=Rand()

取随机值。

整形取值范围为零至给出的最大值减1。

浮点型为零至0.999...

float=Sin(radians)

三角函数。

函数有:

cos,tan,sinh,cosh,tanh,arcsin,arccos,arctan。

float=Log(value)

对数与指数。

Log10,Exp。

float=Sqrt(value)

平方根。

int=CompareFloat(value1,value2,precision)

浮点数比较。

value=Min(value,value{,value})

value=Max(value,value{,value})

获取最大或最小值。

十一、数组:

(略)

十二、执行应用程序与打开文档:

Run(application[,parameter])

可执行文件,快捷方式*.lnk,文档均可,必要时需指定应用程序的完整路径。

例:

Run("

\windows\Pword.exe"

\Mydocuments\doc.psw"

RunWait(application[,parameter])

同上,区别在于:

1.本命令直到执行程序执行结束后,才继续下一条命令。

2.不能使用快捷方式*.lnk文件。

RunAt(Unixtimestamp,application[,parameter])

RunAt(year,month,day,hour,minute,applikation[,parameter])

于指定时间运行程序。

PC上无效,部分WM5系统的PPC无效。

RunOnPowerOn(application[,parameter])

RemoveNotifications(application,[parameter])

十三、应用程序窗口:

Show(window):

据标题显示并激活一个窗口。

注意标题不要使用特殊点及大写。

Minimize(window)

据标题隐藏并最小化一个窗口。

Close(window)

据标题关闭并结束一个窗口。

部分特殊程序不支持。

window=ActiveWindow()

获取一个活动窗口的标题。

bool=WndActive(window)

检查一个窗口是否被激活。

返回的是一个布尔值。

bool=WndExists(window)

检查一个窗口是否存在。

WaitFor(window,seconds)

据时等到窗口存在。

WaiForActive(window,seconds)

据时等到窗口激活。

string=WindowText(x,y)

获取窗口标题/内容元素。

GetWindowPos(window,left,top,right,bottom)

int=WndLeft(window)

int=WndRight(window)

int=WndTop(window)

int=WndBottom(window)

获取窗口坐标,左,右,上,下位置。

十四、键操作:

键盘、鼠标(触笔)

SendCommand([window,]commandid)

SendOK[(window)]

SendCancel[(window)]

SendYes[(window)]

SendNo[(window)]

发送特殊命令。

省略窗口标题指定,则对当前激活窗口进行操作。

PostMessage([window,]messageid,wparam,lparam)

SendMessage([window,]messageid,wparam,lparam)

int=SendMessage([window,]messageid,wparam,lparam)

发送高级命令消息。

SendKeys([window,]string)

模拟打字。

SendSpecial(keyname[,state])

模拟按键。

键名字符串不区分大小写。

省略窗口标题参数,则对当前激活窗口作用。

状态参数:

省略时相当于短按或松开。

设为down和up时,

相当于按下不放。

可模拟键:

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。

Snapshot[(window)]

抓屏至剪切板。

SendCtrlKey([window,]key)

发送CTRL+指定键至指定窗口。

键名不区分大小写。

MouseClick([window,]x,y)

RightMouseClice([window,]x,y)

MiddleMouseClick([window,]x,y)

模拟鼠标单击,坐标位置从左上角开始。

MouseDbClick([window,]x,y)

RightMouseDbClice([window,]x,y)

MiddleMouseDbClick([window,]x,y)

模拟鼠标双击。

MouseDown([window,]x,y)

MouseUp([window,]x,y)

RightMouseDown([window,]x,y)

RightMouseUp([window,]x,y)

MiddleMouseDown([window,]x,y)

MiddleMouseUp([window,]x,y)

模拟鼠标压、放操作。

十五、等待、延时:

Sleep(milliseconds)

暂停指定时间,单位毫秒。

SleepMessage(seconds,message[,title[,OKallowed?

[,condition]])

倒计时消息框。

十六、时间:

int=TimeStamp()

int=MakeTimeStamp(year,month,day[,hour[,minute[,second]]])

返回1970-01-01后的系统当前时间。

string=FormatTime(format[,timestamp])

时间的格式输出:

H:

Hour(00-23)

h:

Hour(01-12)

a:

am/pm

A:

AM/PM

i:

Minute(00-59)

s:

Seconds(00-59)

d:

Day(01-31)

m:

Month(01-12)

Y:

Year(4digits)

y:

Year(2digits)

w:

Dayofweek(0=Sundayto6=Saturday)

u:

Unixtimestamp

{MM}:

如January

{M}:

如Jan

{WW}:

如Monday

{W}:

如Mon

GetTime(variable,variable,variable,variable,variable,variable)

获取系统当前时间。

时分秒日月年。

SetTime(hour,minute,second[,day,month,year])

SetDate(day,month,year)

设置系统时间、日期。

十七、文件、目录的操作:

Copy(sourcefile,targetfile[,overwrite?

单文件复制。

overwrite取值为true或false,决定当存在目标文件时,是否覆盖。

XCopy(sourcefiles,targetdirectory[,overwrite?

[,subdirs?

]])

多文件、文件夹复制。

源文件可使用*和?

通配符。

subdirs决定是否包括子文件夹。

Rename(sourcefile,targetfile[,overwrite?

重命名或移动文件。

Move(sourcefiles,targetdirectory[,overwrite?

多文件或文件夹的移动。

Delete(files)

删除文件。

支持通配符和路径。

DelTree(files)

删除文件夹。

CreateShortcut(shortcutfile,targetfile[,overwrite?

创建快捷方式。

CreateShortcut("

\windows\startmenu\test.lnk"

\storage\test.exe"

true)

MkDir(directory)

创建文件夹。

不能一次创建多层文件夹。

RmDir(directory)

删除一个空文件夹。

ChDir(directory)

切换当前文件夹。

相当于电脑DOS里的CD命令。

仅适用于PC。

x=SystemPath(type)

获取系统路径。

type必须为字符串,如:

"

StartMenu"

type的几个常用参数:

ProgramsMenu:

开始菜单里的Programs。

StartMenu:

开始菜单。

smartphones不适用。

ScriptExe:

主程序MortScript所在路径。

ScriptPath:

当前脚本所在路径。

ScriptName:

当前脚本名称。

ScriptExt:

当前脚本

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1