Skip to contentSkip to Content
Language guideSystem & device commands

System & device commands

These commands interact directly with the physical Upload button on the Mantis device.

WAIT_FOR_BUTTON_PRESS

Halts the entire script until the physical Upload button on Mantis is pressed, then continues execution.

wait.mantis
1REM Set typing speed
2SET_SPEED $Human
3
4STRING waiting for user input...
5REM Pause script completely until button is pressed
6WAIT_FOR_BUTTON_PRESS
7STRINGLN Continuing after the press.

BUTTON_DEF … END_BUTTON

Defines a background handler block that runs whenever the button is pressed while the rest of the script is executing. The main script pauses at the next safe point, the handler runs, and then the main script picks back up exactly where it left off.

This is perfect for triggering an app or payload repeatedly on demand.

button-def.mantis
1REM Define the background handler to open an app
2BUTTON_DEF
3 REM Set typing speed for the handler
4 SET_SPEED $Human
5
6 REM Open the run dialog
7 GUI r
8 DELAY 500
9
10 REM Type the app name and execute
11 STRINGLN calc.exe
12END_BUTTON
13
14REM Main script execution
15REM Set typing speed for the main script
16SET_SPEED $Human
17
18STRING This script is running...
19DELAY 5000
20STRING ...and you can press the button at any time to open the calculator.
  • Only one BUTTON_DEF is allowed per script.
  • A BUTTON_DEF can’t be defined inside a FUNCTION, and a FUNCTION can’t be defined inside a BUTTON_DEF — but the handler body can call functions defined elsewhere.
  • If a WAIT_FOR_BUTTON_PRESS is actively waiting when the button is pressed, that wait is satisfied first — the handler does not also fire for that same press.
Note:

Once the main script finishes, if it defined a BUTTON_DEF, Mantis stays resident and keeps running the handler on every subsequent press for as long as it’s plugged in.

BUTTON_PRESSED (Condition)

Unlike the commands above which wait or run in the background, BUTTON_PRESSED is a boolean condition used inside IF blocks to actively check if the button is currently being held down.

This is highly useful inside LOOP blocks to break out of continuous actions.

button_pressed.mantis
1REM Set typing speed
2SET_SPEED $Human
3
4REM Loop infinitely
5LOOP
6 REM Check if the button is currently held down
7 IF BUTTON_PRESSED THEN
8 STRINGLN The button was detected! Breaking the loop.
9 BREAK
10 END_IF
11
12 REM Do some work while waiting
13 STRING .
14 DELAY 1000
15END_LOOP
Last updated on