-
Notifications
You must be signed in to change notification settings - Fork 0
Script functions
Provided functions in MonkeyKing script.
- float: python builtin float type
- int: python builtin int type
- str: python builtin string
- bool: python builtin boolean
- position: A tuple of int eg, (100, 240) or a position ID in config file.
- pointer: A checkpoint name in string or a line number.
A branch flag is a bool variable that is shared over the whole program. You can only set it to be True or False by branch-screen function. Its main function is to work together with conditional jump functions to manipulate script flow.
Tell monkey king to wait the target screen appears. Check by screen image comparison.
Usage: wait-screen <screenId> <maxAttempt> <interval> <threshold> <optional>
Parameters:
- screenId(str), Screen ID in config, Default: None
- maxAttempt(int), Max attempt count, Default: DEFAULTS['waitUntilScreenMaxAttempt']
- interval(int), Time wait between attempt, Default: DEFAULTS['waitUntilScreenInterval']
- threshold(float), Percentage of match with current screen and Screen ID, Default: DEFAULTS['checkScreenThreshold']
- optional(bool), If this step failed will stop further automation if not optional, Default: False
Mark branch flag to be True or False with check by screen image comparison.
Usage: branch-screen <screenId> <threshold>
Parameters:
- screenId(str), Screen ID in config, Default: None
- threshold(float), Percentage of match with current screen and Screen ID, Default: DEFAULTS['checkScreenThreshold']
Tell monkey king to tap on (DEFAULTS['screenCenter']) to pass screen until target screen appears. Check by screen image comparison.
Usage: tap-until-screen <screenId> <maxTap> <interval> <threshold> <optional>
Parameters:
- screenId(str), Screen ID in config, Default: None
- maxTap(int), Maximum tap attempt before screen appears, Default: DEFAULTS['waitUntilScreenMaxAttempt']
- interval(int), Time wait between tap attempt, Default: DEFAULTS['waitUntilScreenInterval']
- threshold(float), Percentage of match with current screen and Screen ID, Default: DEFAULTS['checkScreenThreshold']
- optional(bool), If this step failed will stop further automation if not optional, Default: False
Tell monkey king to tap on screen position to pass target screen. Check by screen image comparison.
Usage: pass-screen <screenId> <maxAttempt> <interval> <threshold> <position> <optional>
Parameters:
- screenId(str), Screen ID in config, Default: None
- maxAttempt(int), Max attempt count, Default: DEFAULTS['waitUntilScreenMaxAttempt']
- interval(int), Time wait between attempt, Default: DEFAULTS['waitUntilScreenInterval']
- threshold(float), Percentage of match with current screen and Screen ID, Default: DEFAULTS['checkScreenThreshold']
- position(position), Tap position on screen, Default: Use position ID "pass-{screenID}" or None if position ID is not present in config
- optional(bool), If this step failed will stop further automation if not optional, Default: False
Tell monkey king to wait an amount of time.
Usage: sleep <duration>
Parameters:
- duration(float), Time in float, Default: 0
Tell monkey king to run a command on device.
Usage: shell <cmd>
Parameters:
- cmd(str), Command string, Defulat: ''
Tell monkey king to tap on a position.
Usage: tap <position>
Parameters:
- position(position), Tap position on screen, Default: None
Tell monkey king to hold touch on a screen position.
Usage: hold <position>
Parameters:
- position(position), Hold position on screen, Default: None
Tell monkey king to release hold touch event.
Usage: release
No parameters.
Tell monkey king to perform drag gesture on screen.
Usage: drag <from> <to> <duration>
Parameters:
- from(position), Start position, Default: None
- to(position), End position, Default: None
- duration(float), Time will be used to move from start position to end position, Default: 0
Tell monkey king to press a key. Code reference from https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MENU
Usage: press <keyCode>
Parameters:
- keyCode(str), Key code to be pressed, Default: None
Tell monkey king to type a string.
Usage: input-text <text>
Parameters:
- text(str), String content, Default: ''
Start the game or go back the game.
Usage: bootup
No parameters.
Close the game.
Usage: shutdown
No parameters.
Go to desktop screen.
Usage: desktop
No parameters.
Save related files in the game folder to your computer. This will use config file.
Usage: backup-game
No parameters.
Reset the game start from beginning. This will use config.
Usage: reset-game
No parameters.
Tell monkey king to jump to target script label line or a line number.
Usage: jump <target>
Parameters:
- target(pointer), Go to target line, Default: None
Tell monkey king to jump to target script checkpoint line or a line number if branch flag is True.
Usage: jump-true <target>
Parameters:
- target(pointer), Go to target line, Default: None
Tell monkey king to jump to target script checkpoint line or a line number if branch flag is False.
Usage: jump-false <target>
Parameters:
- target(pointer), Go to target line, Default: None
Mark current line to be checkpoint with an unique name. Uses for jump functions.
Usage: checkpoint <id>
Parameters:
- id(str), Checkpoint name, Default: None
Terminate whole program.
Usage: exit <message>
Parameters:
- message(str), Display message, Default: 'No info'
Save current screen to a file.
Usage: save-snapshot
No parameters.
Usage: save-result-screen
No parameters.