> Forums > Windows Mobile

M

MortScript

Erstellt
Mär. '09
letzte Antwort Antworten
3
Aufrufe
10.6T
4
„Gefällt mir“
Abos
Noch keine
Di., 03. März, 2009 um 21:36
#1

MortScript kann eine einfache Scriptsprache interpretieren und ausführen.
Damit lassen sich gut Abläufe automatisieren oder Dinge bewerkstelligen, die sonst unmöglich wären (Das löschen von Systemdatenbanken beim Soft-Reset etwa).




Download MortScript-4.2.zip (2.59 MB, 9 mal)
MD5: 43c6524d57c4737f1fe7f61208b220d0
SHA1: 8efcd30a32b3a6d4774d9f691ff80569d99cc7e5
CRC32: 254fb817


Di., 03. März, 2009 um 21:38
#2

Hier findet ihr ganze viele Skripte und Beispiele...

http://forum.xda-developers.com/showthread.php?t=289197

Di., 03. März, 2009 um 21:39
#3

Und hier noch die zusammenfassung der Kommandos:


This is a quick overview. Please read the manual (readme.txt) for details!

Syntax
======
Allowed parameter formats:
- "string"
quoted string: contained whitespaces remain unmodified, use double quotes
to include quotes (e.g. "This is ""quoted""&quot, ^CR^=carriage return,
^LF^=line feed, ^NL^=new line (Windows/DOS = ^CR^^LF^), ^TAB^=tabulator.
- variable
contents of the variable
- expression
result of the expression, e.g. "Variable = "&variable
- referred variables
The (string) result of an expression in square brackets is used as variable name,
e.g. " ] could refer to the variable "myArray".

For assignments (variable = expression), array indexes, and in expressions,
percent signs around variables are optional (i.e., %x% = %y% is the
same as x = y), strings must be quoted.

For boolean parameters (yes/no, true/false), 1 is yes/true, 0 is no/false.
There are also these predefined variables:
ON, YES, TRUE = 1
OFF, NO, FALSE = 0
CANCEL = 2
PI = 3.1415...
PHI = 1.618...
EULERT = 2.7182... (e)
SQRT2 = 1.4142... (sqare root of 2)

Lines can be continued by using "\" as last character. Example:
Message message, \
"Title"

Comments must start with "#" (trailing whitespaces are allowed). Example:
# This is a comment

Expressions
===========
Strings: "any text, ""in quotes"""
Numbers: 123 (only integer operations!)
Variables: variable, array

Operators by priority (highest first):
() Brackets
NOT Negation (True<->False)
^ Power (5^2=5*5)
* / MOD Multiplication, division, modulo (remainder, integer only)
+ - Addition, subtraction
& \ String concatenation (\ for paths)
>, >=, <, <=, =, <> Numerical comparsions
gt, ge, lt, le, eq, ne Alphanumerical comparsions
c?a:b If c is TRUE, evaluates to a, otherwise b
AND && Binary/logical and
OR || Binary/logical or

Numerical and alphanumerical comparsions have same priority,
they're only splitted for better overview.
AND and OR use binary logic, i.e. 3 AND 7 will return 3 (111 AND 011 = 011),
while && and || use "C logic", i.e. everything that's not 0 is "true" (1), so
3 && 7 will return 1.

Available commands and functions
================================

If "<type> =" is used, it is a function. This means, it returns a value and must be
used in an expression (command parameter or condition). For example:
var = Input( "Enter value" )
If( wndExists( "Explorer" ) )
...
EndIf
Message( "Your input: " & Input( "Value:" ) )

Error handling
--------------
ErrorLevel( "off"|"critical"|"syntax"|"error"|"warn" )

Variables
---------
Set( <variable>,<expression> ) (better use <variable> = <expression&gt
<variable> = <expression>
also allowed: +=, -=, *=, /=, &=, \=; e.g. x/=2 meaning the same as x=x/2
Clear( <variable> )
bool = IsEmpty( <variable> )
int = VarType( <variable> ) - returns VAR_EMPTY, VAR_INT, VAR_FLOAT, VAR_STRING, or VAR_ARRAY
Local( )
Global( <variable> {, <variable} )

String operations
-----------------
string = Part( <string>,<seperator>,<index> )
int = Length( <string> )
string = SubStr( <string>,<start>,<length> )
string = CharAt( <string>,<position> )
int = Find( <string>,<search string> )
string = Replace( <string>,<search string>,<new string> )
int = ReverseFind( <string>,<search character> )
string = ToUpper( <string> )
string = ToLower( <string> )
string = RepeatString( <string>, <count> )
string = UCChar( <unicode value> )
string = UCValue( <character> )

Math / floating point operations
--------------------------------
string = Format( <number>, <digits after decimal point> )
string = NumberToHex( <number> )
int = HexToNumber( <string with hex number> )
int = Ceil( <number> )
int = Floor( <number> )
int = Round( <number> ) (<.5 floor, >=.5 ceil)
float = Sin( <radians> ) (radians = degree*PI/180)
float = Cos( <radians> )
float = Tan( <radians> )
float = Log( <number> ) (based to EULERT / "e&quot
float = Log10( <number> ) (based to 10)
float = Sqrt( <number> ) (square root)
int = CompareFloat( <number>, <number>, <precition> )
value = Min( <value>, <value> {,<value>} )
value = Max( <value>, <value> {,<value>} )

Array operations
----------------
Split( <string>,<seperator>,<trim?>,<variable>{,<variable>} ) (if only one variable, it's used as array)
array = Split( <string>,<seperator> )
array = Array( value {, value } )
array = Map( key, value {, key, value} )
int = MaxIndex( array ) (last defined element with numerical index starting from 1)
int = ElementCount( array ) (complete count of all elements, incl. alphanumerical indexes and cleared entries)

Evaluate expressions in strings
-------------------------------
value = Eval( <expression as string> ) (e.g. res = Eval("var" & index & " & ""...""&quot )

Execution
---------
Run( <application> )
RunWait( <application> )
New( <menu entry> ) (Windows Mobile only)

RunAt( <unix timestamp>, <application> )
RunAt( <year>, <month>, <day>, <hour>, <minute>, <application> )
RunOnPowerOn( <application> )
RemoveNotifications( <application> )

Window control
--------------
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
SendCancel
SendYes
SendNo
SendCommand( <command id> )
SendMessage( <message id>, <wparam>, <lparam> ) (only numerical parameters supported!)
int = SendMessage( <message id>, <wparam>, <lparam> ) (same as above as function)
PostMessage( <message id>, <wparam>, <lparam> ) (only numerical parameters supported!)

Sending keys
------------
SendKeys( <string> )
Send<special character>
Special charaters: CR, Tab, Esc, Space, Backspace, Delete, Insert
Up, Down, Left, Right, Home, End, PageUp, PageDown,
LeftSoft, RightSoft, Win, Context
Snapshot
SendCtrlKey( <key> )

Sending taps ("mouse events&quot
-----------------------------
MouseClick( <x>,<y> )
MouseDblClick( <x>,<y> )
MouseDown( <x>,<y> )
MouseUp( <x>,<y> )

PC version only: Prefix with "Middle" or "Right" for those buttons, e.g. RightMouseClick(...)

Waiting
-------
Sleep( <milliseconds> )
SleepMessage( <seconds>,<message>]] )
WaitFor( <window title>,<seconds> )
WaitForActive( <window title>,<seconds> )

Time
----
int = TimeStamp() (local time as Unix timestamp)
int = TimeStampUTC() (UTC time as Unix timestamp)
string = FormatTime( <format> ) (formatted)
string = TimeZoneName() (Name of current timezone)
int = TimeZoneBias() (offset to UTC in minutes)
bool = TimeZoneDST() (Daylight Saving Time active?)
int = MakeTimeStamp( <year>, <month>, <day>]] )
GetTime( <hour>,<minute>,<seconds> ) (variable references!)
SetTime( <hour>,<minute>,<seconds> )
SetDate( <day>,<month>,<year> )

FormatTime format strings:
H = hour (24h)
h = hour (12h)
i = minute
s = second
d = day of month
m = month
Y = year (4 digits)
y = year (2 digits)
w = day of week (0=sunday,1=monday,...)
u = unix time stamp
A = AM/PM
a = am/pm
{MM} = month name (localized by system)
{M} = month abbrevation (localized by system)
{WW} = name of day (Monday etc., localized by system)
{W} = abbreviated name of day (localized by system)

Copy, rename, move, delete files
--------------------------------
Copy( <source file>,<target file> )
XCopy( <source files>,<target directory>] )
Rename( <source file>,<target file> )
Move( <source files>,<target directory>] )
Delete( <files> )
DelTree( <files or directory> )
CreateShortcut( <shortcut file>,<target file> )

Read and write text files
-------------------------
string = IniRead( <file/url>,<section>,<key> )
IniWrite( <file>,<section>,<key>,<value> )
string = ReadFile( <file/url> ] )
string = ReadLine( <file/url> )
WriteFile( <file>,<contents>] )

COM access
----------
SetComInfo( <port>, <timeout> [, <baud rate> [, <parity> [, <bits>
]]]] )
port: "COM1:" to "COM9:"
baud rate: usually one of 4800, 9600, 19200, 38400, 57600, 76800, 115200
parity: "none", "even", "odd", "mark", "space"
bits: 4-8, usually 8
stop bits: 1, "1.5", 2
control: "none", "RTS/CTS", "XON/XOFF"


File system informations
------------------------
bool = FileExists( <file> )
bool = DirExists( <directory> )
int = FileCreateTime( <file> )
int = FileModifyTime( <file> )
int = FileSize( <file> ) (max. 2147483647)
int = FreeDiskSpace( <directory> ) (max. 2147483647)
int = TotalDiskSpace( <directory> ) (max. 2147483647)
bool = FileAttribute( <file>, <attribute> )
bool = SetFileAttribute( <file>, <attribute>, <set?> )
Allowed values for "attribute":
hidden, readonly, system, archive (<- changeable)
directory, romfile, compressed (<- cannot be set, romfile only for WM)
SetFileAttribs( <file>,<readonly>] ) (1=set,0=remove,""/omit=keep)
string = FileVersion( <file> )
GetVersion( <file>,<variable>,<variable>,<variable>,<variable> )
array = DirContents( <directory>, <type> ) (type = DC_FILES, DC_DIRS, or DC_ALL)

Zip files
---------
Please note: ZIP doesn't support Unicode for filenames.
MortScript uses the old DOS encoding 437, like most popular ZIP progrograms.
I.e., you might get troubles with (un)zipping files with non-ASCII characters.
Rate: 0=no compression, 9=highest

ZipFile( <source file>,<zip file>,<filename in archive> )
ZipFiles( <source files>,<zip file>]] )
UnzipFile( <zip file>,<filename in archive>,<target file> )
UnzipAll( <zip file>,<target directory> )
UnzipPath( <zip file>,<path in archive>,<target directory> )

Connections
-----------
Connect( <connection name> ) for fixed connection name
Connect( <title>, <message> ) for selection of connections
Connect for default http connection
CloseConnection closes only connection established by "Connect"
Disconnect closes all connections (GPRS, ActiveSync, ...)
bool = Connected()
bool = InternetConnected( )
SetProxy( <proxy> ) not necessary if Connect was used
Download( <url>,<target file> )

Directory operations
--------------------
MkDir( <directory> )
RmDir( <directory> )
ChDir( <directory> ) PC version only!
SystemPath( <path> )
valid values for path: ProgramsMenu, StartMenu, Startup, Documents, ProgramFiles,
ScriptExe, ScriptPath, ScriptName, ScriptExt

Registry
--------
RegWriteString( <root>,<path>,<key>,<value> )
RegWriteDWord( <root>,<path>,<key>,<value> )
RegWriteBinary( <root>,<path>,<key>,<value> )
RegWriteMultiString( <root>,<path>,<key>,<value> ) (value should be an array)
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".

Dialog
------
string = Input( <message> ]]] )
Message( <text> )
SetMessageFont( <font size>, <font name> ) (for BigMessage, SleepMessage, Input; Message uses a system dialog that doesn't support own fonts!)
BigMessage( <text> )
SleepMessage( <seconds>,<message>]] )
int = Question( <message> ] ) (Type=OkCancel,YesNo,YesNoCancel; Yes/OK=1,No=0,Cancel=2)
SetChoiceEntryFormat( <item height> )
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> )
string = SelectFile( <title>, <save?> ]] )

Status window
-------------
StatusInfo( <title> ) (title and list info text)
StatusType( ST_HIDDEN|ST_LIST|ST_MESSAGE ] )
StatusHistorySize( <count> ) (number of entries in list)
StatusMessage( <message> ]] )
StatusMessageAppend( <message> ) (appends last message)
StatusRemoveLastMessage()
StatusClear() (removes all previous messages)
StatusShow() (bring status window to foreground)
StatusListEntryFormat( <item height> )
WriteStatusHistory( <file name> ] )

Processes
---------
bool = SupportsProcHandling() (For PNAs, check if ProcExists and Kill will work)
bool = ProcExists( <process name> )
bool = ScriptProcExists( <script name> )
string = ActiveProcess( )
string = WindowProcess( <window title> )
Kill( <process name> )
KillScript( <script name> )

Signals
-------
int = GetVolume() (Windows Mobile only)
SetVolume( <value> ) (Windows Mobile only)
PlaySound( <wav file> )
Vibrate( <milliseconds> )

Display/screen
--------------
int = ColorAt( <x>,<y> )
int = RGB( <red>,<green>,<blue> )
int = Red( <color> )
int = Green( <color> )
int = Blue( <color> )
array = ScreenToChars( <x>, <y>, <width>, <height>, <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" )
int = ScreenWidth()
int = ScreenHeight()
string = CurrentCursor( ) (returns "arrow", "wait", "cross", "help", or "uparrow&quot
RedrawToday
ShowWaitCursor
HideWaitCursor

Clipboard
---------
SetClipText( <text> )
string = GetClipText()

Memory
------
int = FreeMemory( ) (max. 2147483647)
int = TotalMemory( ) (max. 2147483647)

Energy
------
bool = ExternalPowered()
int = BatteryPercentage()
int = BackupBatteryPercentage()
PowerOff
IdleTimerReset (Windows Mobile only)

System
------
MortScriptType()
string = MortScriptVersion() (similar to FileVersion)
GetMortScriptVersion( <variable>,<variable>,<variable>,<variable> ) (similar to GetVersion)
value = SystemVersion( )
element: "major", "minor", "build", "platform", omit for major.minor.build
Reset (Windows Mobile only)

Control structures
==================
If ( <condition> )
{ ElseIf ( <condition> ) }

EndIf

Choice ( <title>,<message>,<text1> )
| ChoiceDefault ( <title>,<message>,<default>,<timeout>,<text1>, )
Case ( <index> )
EndChoice
(if only one text is given, it's assumed to be a array variable)

Switch ( <value> )
Case ( <index> )
EndSwitch

While ( <condition> )
EndWhile

Repeat ( <count> )
EndRepeat

For <variable> = <value> to <value>
Next

ForEach <variable> in values ( <value>{,<value>} )
| ForEach <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&quot"
or use the old syntax without parentheses, like "Call MySubRoutine&quot.

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

Include( <filename> ) (includes Sub/EndSub blocks of other files)

Exit


Old conditions
==============
Only for compatibility, please use functions instead!
I.e. "If ( wndExists( "window" ) )" instead of "If wndExists "window"".

equals <value1>,<value2>
expression <expression>
fileExists <file>
dirExists <directory>
procExists <application>
wndExists <window title>
wndActive <window title>
question <text>
screen landscape|portrait|vga|qvga
regKeyExists <root>,<path>,<key>
regKeyEqualsString <root>,<path>,<key>,<value>
regKeyEqualsDWord <root>,<path>,<key>,<value>


Obsolete commands
=================
These commands are for backward compatibility, you should use the new functions instead.

Eval <variable>,<expression as string> (e.g. { "%var" & %index% & "% & ""...""" })
Input <variable>,<numeric?>,<message>
GetPart <string>,<seperator>,<trim?>,<index>,<variable>
SubStr <string>,<start>,<length>,<variable>
Find <string>,<search string>,<variable>
ReverseFind <string>,<search character>,<variable>
MakeUpper <variable>
MakeLower <variable>
GetRGB <red>,<green>,<blue>,<variable>
GetActiveWindow <variable>
GetVersion <file>,<variable>
IniRead <file/url>,<section>,<key>,<variable>
ReadFile <file/url>,<variable>
GetSystemPath <path>,<variable>
RegReadString <root>,<path>,<key>,<variable>
RegReadDWord <root>,<path>,<key>,<variable>
RegReadBinary <root>,<path>,<key>,<variable>
Input <variable>,<numeric?>,<message>
GetMortScriptType <variable>
GetSystemPath ,<variable>
GetColorAt <x>,<y>,<variable>
GetWindowText <x>,<y>,<variable>
GetClipText <variable>
GetActiveProcess <variable>

Di., 03. März, 2009 um 21:41
#4

Aufgund der Zensurfunktion nier nochmal als TXT:


Download commands.txt (20.01 kB, 3 mal)
MD5: 70ea18a4bd965bdba798f6b0e33d6afa
SHA1: db55f7f1865c5d7c0cfa70e8e8d79d21ec2d9850
CRC32: 8485104a


> Forums > Windows Mobile

Du hast bereits für diesen Post abgestimmt...

;-)



Logo https://t.ress.at/RxDXX/




Top