Command line

Everything from a terminal.

rex.exe is on your PATH after installing. In a checkout, use REX.bat the same way.

For scripts and coding agents

Start with rex agent, or add --json anywhere. Every command then writes exactly one JSON document, never prompts, contains no colour codes, and exits 0 on success and 1 on failure.

{"ok":true,"protocolVersion":2,"command":"status","data":{...}}
{"ok":false,"protocolVersion":2,"command":"action","error":{"type":"InvalidOperationException","message":"..."}}

Ask rex agent capabilities first: it lists every command, action, phone setting and config path this version knows. With more than one phone connected, pass --serial; the command line never guesses between phones.

Every command

Commands marked needs the app act on the open window; start it with rex open first. The rest work on their own, over ADB.

rex open

Open the app, or bring it to the front.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex open

rex status

App, mirror and phone state.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex status

rex devices

Phones visible to ADB.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex devices

rex stop

Stop the mirror. The app stays in the tray.

Output
Both: plain text, or JSON with --json
Needs the app
Yes
rex stop

rex quit

Exit the app completely.

Output
Both: plain text, or JSON with --json
Needs the app
Yes
rex quit

rex action <name> [--serial S]

Send an action: home, back, sleep, volume, rotation and the rest. rex action list shows the names.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex action sleep

rex zoom <in|out|reset>

Zoom the PC view of the open mirror.

Output
Both: plain text, or JSON with --json
Needs the app
Yes
rex zoom in

rex sound [0-100|up|down|mute|unmute|toggle]

The phone's sound on this PC: a level, louder, quieter or muted. Without a value, what it is now.

Output
Both: plain text, or JSON with --json
Needs the app
Yes
rex sound 40

rex app list [search] [--system] [--serial S]

The phone's apps by name. A search finds the phone's own apps too; --system lists them all.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex app list spot

rex app open <name|package> [--fresh] [--serial S]

Open an app by its name or package. --fresh closes it first.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex app open Spotify

rex app close|info <package> [--serial S]

Close an app completely, or open its info page on the phone.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex app close com.spotify.music

rex app favourite <package> on|off [--serial S]

Star an app, or take its star away. Favourites have tiles and keys in the app.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex app favourite com.spotify.music on

rex push <files or folders…> [--to /sdcard/folder/] [--serial S]

Copy files or folders into the phone's shared storage.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex push photo.jpg --to /sdcard/Pictures/

rex install <apk…> [--downgrade] [--grant] [--test] [--no-replace] [--serial S]

Install one or more APK files, with optional update flags.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex install app.apk --grant

rex screen [open <app> [--instead|--beside] [--size follow|phone|720p|1080p|1440p|WxH] [--fresh] | app <app> | close]

A second screen for one app, beside the phone or instead of it: open it, switch its app, close it, or see what it is doing.

Output
Both: plain text, or JSON with --json
Needs the app
Yes
rex screen open YouTube --size 1080p

rex profile list | show <name> | apply <name> | save <name> [--groups Mirror,Sound] [--all] | rename <old> <new> | delete <name> | export <name> <file> | import <file>

Profiles: lists of settings to switch to in one go. Save the settings you have now, apply one or a preset, and share them as files. Works with or without the app.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex profile apply Gaming

rex phones [beside [serial] | stop | switch | make-main]

Every connected phone and where it shows: the main phone, the one beside it, and the one in use. With the app running, show one beside, stop it, switch to the other, or swap them.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex phones beside

rex encoders [--serial S]

The phone's video encoders, to choose one with rex config set Mirror.VideoEncoder. Works with or without the app.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex encoders

rex keys [set <action> <key|none> | reset [action]] [--browse]

Every key the window and browse mode answer to. Give any action a key, take one away, or put them back. Works with or without the app.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex keys set home Ctrl+Alt+J

rex screenshot [--serial S]

Save a picture of the phone screen.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex screenshot

rex phone list|get [filter]

Every phone setting this phone offers, with its value.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex phone list bright

rex phone set <setting> <value>

Change one phone setting (rex phone list shows the ids).

Output
Both: plain text, or JSON with --json
Needs the app
No
rex phone set brightness 180

rex phone reset <setting>

Let Android use its own default for a phone setting again.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex phone reset font_scale

rex android list|get|set|delete <system|secure|global> [key] [value] [--filter text]

Raw Android settings. Keys that could cut off ADB are refused.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex android list global --filter animation

rex config list|get|set|restore [path] [value]

The app's own settings in config.json. set keeps a backup; restore swaps it back.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex config set Mirror.MaxFps 90

rex autostart <on|off>

Start with Windows, or not.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex autostart on

rex lock-mode <serial> <pattern|other|none>

Say what kind of lock screen a phone has.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex lock-mode R3CR... pattern

rex reset-lock [serial|ALL]

Forget the lock-screen answers for one phone, or all.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex reset-lock ALL

rex setup

Download and check the official scrcpy without opening the app.

Output
Plain text only
Needs the app
No
rex setup

rex usb [list|status]

ADB interfaces, and USB devices Windows could not read.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex usb

rex usb repair [--dry-run]

Repair both. Asks for administrator approval; --dry-run only says what it would do.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex usb repair --dry-run

rex usb enable-auto-repair|disable-auto-repair [--dry-run]

Fix "USB device not recognised" without asking each time, or stop doing so. Asks once.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex usb enable-auto-repair

rex usb run-auto-repair

Start the installed auto-repair now. Needs no approval.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex usb run-auto-repair

rex diagnostics

A full report: versions, files, startup, tools, phones and the recent log.

Output
Both: plain text, or JSON with --json
Needs the app
No
rex diagnostics

rex agent capabilities

The machine-readable contract: commands, actions, settings and paths.

Output
JSON only
Needs the app
No
rex agent capabilities

rex help

This list.

Output
Plain text only
Needs the app
No
rex help