System

Access runtime system/device info and trigger system-level actions from script.

Syntax

System()

Returns

Example

sys = System()
print("sdk=", sys.sdk())
battery = System.battery()
print("battery=", battery.percent, battery.charging)
System.toast("Macro started")
System.play_noti()
System.home()

Fields

NameDescription
devdict
Device capability info (`isEmulator`, `sdk`, `language`, `darkmode`, `touch`, `capture`).
batterydict
Battery info (`percent`, `charging`, `temperature`, `health`).
screendict
Screen info (`width`, `height`, `orientation`, `density`, `dpi`); `orientation` is display rotation in degrees: `0`, `90`, `180`, or `270`.
memorydict
Memory info (`avail`, `total`, `threshold`, `low`).

Methods

20 methods

System.time_ms

Get current timestamp in milliseconds.

Syntax

System.time_ms()

Returns

Number — Epoch milliseconds.

Example

# Query Android or request a documented system action
started = System.time_ms()
wait(100)
print(System.time_ms() - started)

System.app_version

Get app version name.

Syntax

System.app_version()

Returns

String — App version name.

Example

# Query Android or request a documented system action
print(System.app_version())

System.variant

Get the stable code of the macro variant selected for this run.

Syntax

System.variant()

Returns

String — Variant code such as `default` or `pro_plus`.

Example

# Branch by the current macro variant
if System.variant() == "pro_plus":
    print("Pro Plus")

System.open

Open the launchable activity of an installed Android app. CogniTab resolves the standard or Android TV launcher activity from the package name, so the activity class is not required.

Syntax

System.open(package_name)

Parameters

NameDescription
package_nameString
Android application package name, for example `com.android.settings`.
Required · Positional or named
No default

Returns

Boolean — `True` when Android accepts a launch intent; `False` when the app is unavailable, has no launchable activity, or cannot be opened.

Example

# Open Android Settings and handle an unavailable target
opened = System.open("com.android.settings")
if not opened:
    System.toast("App is unavailable")

System.sdk

Get Android SDK int.

Syntax

System.sdk()

Returns

Number — Android SDK version integer.

Example

# Query Android or request a documented system action
print(System.sdk())

System.language

Get current language code.

Syntax

System.language()

Returns

String — Locale language code (for example `en`, `vi`).

Example

# Query Android or request a documented system action
print(System.language())

System.dpi

Get current screen DPI.

Syntax

System.dpi()

Returns

Number — Display density DPI.

Example

# Query Android or request a documented system action
print(System.dpi())

System.darkmode

Check if dark mode is enabled.

Syntax

System.darkmode()

Returns

Boolean — `True` when dark mode is active.

Example

# Query Android or request a documented system action
if System.darkmode():
    print("Dark mode")

System.play_noti

Play system notification sound.

Syntax

System.play_noti()

Returns

None — No return value.

Example

# Query Android or request a documented system action
System.play_noti()

System.toast

Show system toast message. Structured values are rendered with the compact DSL display formatter so the toast stays short and readable.

Syntax

System.toast(text)

Parameters

NameDescription
textAny
Toast text or structured value to display compactly.
Required · Positional or named
No default

Returns

None — No return value.

Example

# Query Android or request a documented system action
System.toast("Macro started")

System.stop

Stop the current macro immediately from script.

Syntax

System.stop()

Returns

None — Stops execution; no return value is observed.

Example

# Query Android or request a documented system action
if Storage.get("stop_requested", False):
    System.stop()
print("Still running")

System.minimized_dock

Query or adjust the minimized overlay dock. The point uses the same coordinate scale and anchor rules as Point-based click targets; width and height are current-screen pixels.

Syntax

System.minimized_dock(point=None, *, width=None, height=None, alpha=None, mode=None)

Parameters

NameDescription
pointPoint?
Optional top-left dock position.
Optional · Positional or named
Default: None
widthNumber?
Optional minimized dock footprint width in pixels.
Optional · Keyword only
Default: None
heightNumber?
Optional minimized dock footprint height in pixels.
Optional · Keyword only
Default: None
alphaNumber?
Optional dock opacity from 0.2 to 1.0.
Optional · Keyword only
Default: None
modeString?
Optional dock presentation. Values: icon or row.
Optional · Keyword only
Default: None

Returns

dict — Applied state with `applied`, `x`, `y`, `width`, `height`, `alpha`, `mode`, and optional `reason`.

Example

# Move, resize, and collapse the minimized dock for this run
System.minimized_dock(Point(24, 120), width=72, height=36, alpha=0.85, mode="icon")

System.back

Perform global Back action.

Syntax

System.back()

Returns

Boolean — `True` if action dispatched.

Example

# Query Android or request a documented system action
print(System.back())

System.home

Perform global Home action.

Syntax

System.home()

Returns

Boolean — `True` if action dispatched.

Example

# Query Android or request a documented system action
print(System.home())

System.recent

Open recents screen.

Syntax

System.recent()

Returns

Boolean — `True` if action dispatched.

Example

# Query Android or request a documented system action
print(System.recent())

System.noti

Open notifications shade.

Syntax

System.noti()

Returns

Boolean — `True` if action dispatched.

Example

# Query Android or request a documented system action
print(System.noti())

System.lockscreen

Lock the current screen.

Syntax

System.lockscreen()

Returns

Boolean — `True` if action dispatched.

Example

# Query Android or request a documented system action
print(System.lockscreen())

System.powerdialog

Open power dialog.

Syntax

System.powerdialog()

Returns

Boolean — `True` if action dispatched.

Example

# Query Android or request a documented system action
print(System.powerdialog())

System.quicksetting

Open quick settings panel.

Syntax

System.quicksetting()

Returns

Boolean — `True` if action dispatched.

Example

# Query Android or request a documented system action
print(System.quicksetting())

System.screenshot

Trigger global screenshot action.

Syntax

System.screenshot()

Returns

Boolean — `True` if action dispatched.

Example

# Query Android or request a documented system action
print(System.screenshot())