Robotmon
  • Robotmon
  • 使用說明
  • 官方腳本
    • 薑餅人王國外掛腳本自動玩
    • POPCAT 台灣爭光
    • TsumTsum 全自動玩、自動收心送心
    • 三麗鷗明星的微笑小鎮 Hello Sweet Days
    • 天堂M外掛 無課救星
    • EZRobot簡易腳本製作
    • YouTube自動刷瀏覽
    • 徵求維護
      • Marvel自動玩外掛
      • 無盡的邊疆自動玩外掛
      • 楓之谷M 自動任務/練等
  • 教學文件
    • 手機快速上手
      • a.開啟手機 USB 偵錯
      • b.安裝手機 ADB 驅動
    • 模擬器快速上手
    • 安裝 SimpleManager
    • 啟動 Robotmon Service
    • App 使用教學
  • 進階使用教學
    • 手動啟動 Robotmon Service
    • Develop Guide
    • Robotmon v2 Beta Testing
  • Robotmon 障礙排除
  • 腳本教學
    • 安裝VSCode編輯器插件
    • Robotmon VSCode 插件功能
    • API Documents
      • JavaScript Events
      • JavaScript Interface
      • JavaScript Raw APIs
      • RBM library APIs
      • gRPC APIs
  • XRobotmon
  • 支援手機列表
    • 確定支援裝置
    • 可能支援手機
  • 隱私權政策
  • Robotmon Messenger
  • Robotmon Announcement
  • Robotmon Store
Powered by GitBook
On this page
  1. 腳本教學
  2. API Documents

RBM library APIs

High level API for controlling your android phone

The RBM library is an API wrapper of the Robotmon JavaScript APIs.

RBM Config

property

description

appName

The name of the script.

oriScreenWidth

The width of developer's phone.

oriScreenHeight

The height of developer's phone.

oriVirtualButtonHeight

The virtual button height of developer's phone(getVirtualButtonHeight()). If no virtual button in app, just set to 0.

oriResizeFactor

The resize ratio of the screenshot in developer's environment. For screencrop(). Range from 0 to 1.

eventDelay

The delay milliseconds of the event.

imageThreshold

The threshold of image recognition. Range from 0 to 1.

imageQuality

The compression level of the image. Range from 0 to 100.

resizeFactor

The resize ratio of the screenshot in user's environment. Same as oriResizeFactor is better. Range from 0 to 1.

Using

// Import RBM library
importJS('RBM-0.0.2');

// Initial RBM config
var config = {
  appName: 'com.your.script',
  oriScreenWidth: 1080,
  oriScreenHeight: 1920,
  oriVirtualButtonHeight: 0,
  oriResizeFactor: 0.6,
  eventDelay: 200,
  imageThreshold: 0.85,
  imageQuality: 80,
  resizeFactor: 0.6,
};

// Create RBM instance
var rbm = new RBM(config);

// Important! Calculate the screen size, call it after start pressed!
rbm.init();

// Then using the following APIs of the RBM library

RBM library

rbm.log(args)
  • args any type - if argument is object, it will convert object to JSON string

For general output of logging information.

rbm.currentApp()

Returns Object - The current app in foreground. {packageName: String, activityName: String}

rbm.startApp(packageName, activityName)
  • packageName String

  • activityName String

Launch an app by packageName and activityName.

rbm.stopApp(packageName)
  • packageName String

Close an app by packageName.

rbm.click(position)
  • position Object - {x: Integer, y: Integer}

rbm.tapDown(position)
  • position Object - {x: Integer, y: Integer}

rbm.tapUp(position)
  • position Object - {x: Integer, y: Integer}

rbm.moveTo(position)
  • position Object - {x: Integer, y: Integer}

rbm.swipe(from, to, steps)
  • from Object - {x: Integer, y: Integer}

  • to Object - {x: Integer, y: Integer}

  • steps Integer - Interpolation points between from and to

rbm.keycode(label)
  • label String

rbm.typing(words)
  • words String

rbm.sleep()

Sleep with eventDelay.

rbm.getImagePath()
// /sdcard/Robotmon/scripts/com.your.app/images

Returns String - The path of the image folder. All about images used in this library will load and save within this folder.

rbm.screenshot(filename)
  • filename String

Save the screenshot in rbm.getImagePath().

rbm.oriScreencrop(filename, fromX, fromY, toX, toY)

// Examples:
rbm.oriScreencrop('startButton.png', 100, 200, 200, 300)
  • filename String

  • fromX Integer

  • fromY Integer

  • toX Integer

  • toY Integer

Crop the original screenshot and save it with filename. This function will resize the image with oriResizeFactor and compress with imageQuality.

rbm.screencrop(filename, fromX, fromY, toX, toY)

// Examples:
rbm.screencrop('startButton.png', 100, 200, 200, 300)
  • filename String

  • fromX Integer

  • fromY Integer

  • toX Integer

  • toY Integer

Crop the screenshot and save it with filename. This function will resize the image with resizeFactor and compress with imageQuality.

rbm.findImage(filename, threshold)

// Examples:
rbm.findImage('startButton.png', 0.9)
  • filename String

  • threshold Float

Returns Object - Find the image with filename in screen. {x: Integer, y: Integer, score: Float}

rbm.findImages(filename, threshold, countLimit, allowOverlap, deep)

// Examples:
rbm.findImages('startButton.png', 0.9, 3, false, false)
  • filename String

  • threshold Float

  • countLimit Integer

  • allowOverlap Boolean

  • deep Boolean

Returns Object - Find the image with filename in screen. {x: Integer, y: Integer, score: Float}

rbm.imageExists(filename, threshold)
  • filename String

  • threshold Float

Returns Boolean - Whether the image is exists in screen.

rbm.imageClick(filename, threshold)
  • filename String

  • threshold Float

Click the image if the image is exists in screen.

rbm.imageWaitClick(filename, timeout, threshold)
  • filename String

  • timeout Integer

  • threshold Float

Click the image if the image is exists in screen until timeout (milliseconds).

rbm.imageWaitShow(filename, timeout, threshold)
  • filename String

  • timeout Integer

  • threshold Float

Block until the image is found or timeout

rbm.imageWaitGone(filename, timeout, threshold)
  • filename String

  • timeout Integer

  • threshold Float

Block until the image is gone or timeout

rbm.keepScreenshot()

Keep the screenshot in memory. To avoid to many times screencap.

rbm.screencrop(fromX, fromY, toX, toY)
  • fromX Integer

  • fromY Integer

  • toX Integer

  • toY Integer

Keep the partial screenshot in memory. To avoid to many times screencap.

rbm.releaseScreenshot()

Release the screenshot in memory.

Using keepScreenshot

// Screencap three times
rbm.imageClick('apple.png', 0.9); // screencap, and release
rbm.imageClick('banana.png', 0.9); // screencap, and release
rbm.imageClick('cat.png', 0.9); // screencap, and release

// Screencap only one time (used when the screen has not changed)
rbm.keepScreenshot(); // screencap
rbm.imageClick('apple.png', 0.9); // no screencap, no release
rbm.imageClick('banana.png', 0.9); // no screencap, no release
rbm.imageClick('cat.png', 0.9); // no screencap, no release
rbm.releaseScreenshot(); // release
PreviousJavaScript Raw APIsNextgRPC APIs

Last updated 7 years ago