-
Notifications
You must be signed in to change notification settings - Fork 0
Contribute in scripting
TODO: support apk version TODO: init script for a bundle. monkeykingproj name
generate: {name}Config.py /caps /screen /script /script/coord1.mks /script/screen1.mks /script/main1.mks TODO: Config resolution
Following keys are required in env config dict:
- GAME_PACKAGE(str): The game package ID.
- RUNNABLE_ACTITVITY(str): Game
launchable-activityname. Can be found byaapttool. - APK_LOCATION(str): Target game APK locate in your computer. Use for game reset and reinstall.
- GAME_PROJECT_PATH(str): Path of the project.
- SCREENS(list): List of screen info dict. Use
SCREEN_FILESinstead. - COORDINATES(list): List of coordinate info dict. Use
COORDINATE_FILESinstead. - SCRIPTS(list): List of script dict. Use
SCRIPT_FILESinstead. - GAME_USER_FILES(list): Path of files to be backed up with backup-game function
- COORDINATE_FILES(list): Load coordinates info from list of files in script format(.mks). Same function as
COORDINATESkey but recommended to use this in order to keep config file clean. - SCREEN_FILES(list): Load screens info from list of files in script format(.mks). Same function as
SCREENSkey but recommended to use this in order to keep config file clean. - SCRIPT_FILES(list): Load scripts from list of script files(.mks). Same function as
SCRIPTSkey but recommended to use this in order to keep config file clean.
Example:
ENV_CONFIG = {
'GAME_PACKAGE': 'jp.co.mixi.monsterstrike', # Game package id
'RUNNABLE_ACTITVITY': 'jp.co.mixi.monsterstrike.SplashActivity', # launchable-activity name
'GAME_PROJECT_PATH': '/Users/makkit/monkeyscript/test/', # Project path. Screen cap will save to this path.
'APK_LOCATION': '', # APK location on your computer
# Files to be backed up by backup-game. These files should be enough to retrieve a game account by placing in the game directory.
'GAME_USER_FILES': [
'/data/data/tw.wonderplanet.CrashFever/shared_prefs/SmartBeat.xml',
'/data/data/tw.wonderplanet.CrashFever/shared_prefs/initPrefs.xml',
'/data/data/tw.wonderplanet.CrashFever/shared_prefs/appsflyer-data.xml',
'/data/data/tw.wonderplanet.CrashFever/shared_prefs/HSJsonData.xml',
],
'COORDINATE_FILES': ['script/coord.mks', 'script/main-flow.mks'], # Load coordinates info from these files.
'SCRIPT_FILES': ['script/part1.mks', 'script/part2.mks'], # Load script from these files.
'SCREEN_FILES': ['script/main-flow-screen.mks', 'script/flow-2.mks'], # Load screens info from these files.
'COORDINATES': [], # Not used because we are using COORDINATE_FILES instead.
'SCREENS': [], # Not used because we are using SCREEN_FILES instead.
'SCRIPTS': [] # Not used because we are using SCRIPT_FILES instead.
}
- Screen info dict is a reference to identify a screen. It should be able to be used in matching a screen. Example:
{
'id': 'title-screen', # Unique ID for a screen
'file': 'cap/title-text.png', # Precropped screencap of that screen. Crop area should be same as rect key of this dict
'rect': (28, 547, 670, 103) # Crop area
},
...
In script.mks:
branch-screen title-screen .
> return True if cropped area(rect) of current screen 90% matches image in file path.
- Screen info script format: . Example:
news-notice . 263,184,233,59 # No file screen infonews-popup cap/news-popup.png 282,1154,144,107 # Screen info with file
- Coordinate info dict is a reference to give a meaning to a point. It is useful for touch event position. Example:
{
'id': 'close-news-button',
'position': (360, 1204)
},
- Coordinate script format: . Example:
pass-title-screen 360,678
Script dict is a dictionary contains the action and all parameters. Example:
{
'action': 'drag',
'from': 'close-app-drag-start',
'to': 'close-app-drag-end',
'duration': 1
}
Monkey King uses default image comparison method to do the screen checking provided by monkeyrunner. It is a simplest pixel-by-pixel checking between two images and then return match level of them. The match level is from 0 to 1 which means 0% to 100% match.
In Monkey King script, there are several function have a parameter called threshold. It indicates the acceptance of matching. Default is 0.9 set in config file which means the function result is True when match level > 0.9 otherwise False.
In the repo, there is a simple script editor that may help you better to write monkey king script. Remember to save your work regularly!
TODO