Sys

Contain various methods to communicate with the system

Static Methods
noti
static void noti(name: string = null)

Notify the user by playing the notification sound. Call this method again or stop the macro will stop the sound immediately

Parameters
name Name of the notification sound on your device. null to use the default
playMedia
static void playMedia(name: string, duration: number = -1, interval: number = 0, repeat: number = 1)

Play media file on the app data folder (/sdcard/Android/data/com.kok_emm.mobile/files)

Parameters
name Name of the file
duration Custom duration. -1 for using the duration of the actual media file. Default: -1
interval Time to wait after each repeat. Default: 0
repeat Number of time to repeat playing the file. Default: 1
toast
static void toast(message: string)

Notify the user by showing a toast message

Parameters
message The message
alert
static void alert(message: string)

Notify the user by showing an alert popup

Parameters
message The message
log
static void log(message: string)

Log message to the console in Play Mode only if "debug" is enabled

Parameters
message The message
err
static void err(message: string)

Notify the user by showing an alert popup and stop the macro

Parameters
message The message
currentTime
static number currentTime()

Return the current time in miliseconds

Return
number The current time
elapsedTime
static number elapsedTime()

Return the time since boot in milliseconds. Should be used to measure duration.

Return
number The time since boot.
currentVersion
static Version currentVersion()

Return the current Version of the app

Return
Version The current Version of the app
sdk
static number sdk()

Return the sdk number of the device

Return
number The sdk number of the device
lang
static string lang()

Return the current language code of the device (en, fr, es, etc...)

Return
string The current language code
dpi
static number dpi()

Return the current dpi

Return
string The current dpi
darkMode
static bool darkMode()

Return true if darkmode is on, false otherwise

Return
bool true if darkmode is on, false otherwise
info
static any info(property: string)

Query information about the system. Some of the calls are expensive so try not to query them in a constant loop manner. Return null if not found

Parameters
property
  • dev.isEmulator: true if emulator (bool)
  • dev.darkmode: true if dark mode is ON (bool)
  • dev.language: Language code of the device (string)
  • dev.sdk: The device sdk version (number)
  • dev.touch: The current touch method: 0 - Accessibility or 1 - Native service (number)
  • dev.capture: The current capture method: 0 - Media projection or 1 - Native service (number)
  • battery.level: Current battery level (number)
  • battery.charge: true if charging (bool)
  • battery.ac: true if charging using AC (bool)
  • battery.usb: true if charging using USB (bool)
  • screen.dpi: The screen dpi (number)
  • screen.xdpi: The screen xdpi (number)
  • screen.ydpi: The screen ydpi (number)
  • screen.state: true if screen is on (bool)
  • screen.timeout: The amount of time in milliseconds before the device goes to sleep (number)
  • screen.cutouts: The device's cutouts (notch). Return array of [left, top, right, bottom] cutouts (array)
  • screen.realCutouts: Similar to screen.cutouts but double checking by parsing the cutout area for actual black pixels (array)
  • screen.insets: Status bar, navigation bar, etc... (array)
  • screen.rotation: Returns the rotation of the screen from its "natural" orientation. Possible values are 0 (no rotation), 1 (90°), 2 (180°), 3 (270°). Rotation is counter-clockwise (number)
  • screen.smallestWidth: Returns the screen smallest width, can be used for app scaling (number)
  • memory.total: RAM size of the device (number)
  • memory.free: The available memory on the system (number)
  • memory.threshold: The threshold of memory.free at which the device considers memory to be low and start killing background services (number)
  • memory.low: Set to true if the system considers itself to currently be in a low memory situation (number)
setControlOpacity (Deprecated)
static void setControlOpacity(opacity: number)

Set the opacity to Play Mode control

Deprecated: Please use Overlay.setOpacity() instead

Parameters
opacity The opacity. Value 0.1-1
globalAction
static void globalAction(action: string)

Perform Global Action. Require Accessibility Service turn on

Parameters
action
  • back: Press the Back button
  • home: Press the Home button
  • recent: Press the Recent button
  • noti: Open notification tray
  • lockscreen: Lock the screen (Android 9+)
  • powerdialog: Open the power dialog (Android 5+)
  • quicksetting: Open quick setting
  • screenshot: Take screenshot (Android 9+)
openApp
static void openApp(packageName: string, activity: string = null)

Open another App

1.3.8+: You only need the packageName on Android 10-. The app will automatically query the main activity. On Android 11+ due to the new restriction you must specify the activity to start using the 2nd parameter.

Parameters
packageName The package name of the app. Ex: com.kok_emm.mobile
activity The main activity to start. You can get this from adb command: "adb shell dumpsys activity" and filter it using grep. Ex: com.kok_emm.mobile.activity.ActivityMain
openUrl
static void openUrl(url: string, newTab: bool)

Open a url with the default browser or pick from browser chooser.

Parameters
url The url to open
newTab true to open in new tab
toggleFeature
static void toggleFeature(feature: number, enable: bool)

Toggle the implemention of some features.

Parameters
feature The feature to toggle.
  • 0 - Color.get
  • 1 - Color.getAll
enable Enable the feature
wake
static void wake()

Wake the screen. "Auto Stop Macro When Screen Off" feature should be turned off. If your keyguard is secured then It'll ask for your interaction otherwise the keyguard is automatically cleared

stop
static void stop()

Stop the macro

© 2024 - Macrorify by KoK-CODE