How To Call It
System is a global table: call its functions with a dot (System.<method>(...)), not a colon. Requires Macro Handler 1.0.62 or later.
Changes the saved screen timeout in whole milliseconds; returns true only after reading back exactly the requested value.
Documented for app version 1.0.64Updated:
System is a global table: call its functions with a dot (System.<method>(...)), not a colon. Requires Macro Handler 1.0.62 or later.
In system flow, design steps as observe first and act second when the API can affect device state.
durationMs: finite integral Lua number from 15000–2147483647. Numeric strings, fractional milliseconds, extra arguments and out-of-range values return false without side effects. No root is required; Android Modify system settings (WRITE_SETTINGS) access is required. Missing access returns false without opening a permission screen or elevating access.
This is Android’s saved screen-timeout setting, not a guarantee that the physical display will turn off after that interval. Device administration, wake locks and app policies may affect behavior. Settings reads/writes do not run on the main UI thread; stopped operations return false/nil.
No-Code/Logic: System → Android Actions → Screen timeout. Automation.action("screen_timeout", {duration=30, unit="s"}) uses the same operation and raises an error on failure. Units are ms/s/min, default 30 s. Input accepts at most six decimal places; conversion must produce whole milliseconds without rounding.
The snippet below is a starter pattern that can be applied directly in runtime flow.
local verified = System.setScreenTimeout(60000)
print("Saved timeout verified", verified)From foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
local verified = System.setScreenTimeout(60000)
print("Saved timeout verified", verified)local stepOk = true
local verified = System.setScreenTimeout(60000)
print("Saved timeout verified", verified)
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
local verified = System.setScreenTimeout(60000)
print("Saved timeout verified", verified)
end)
if not ok then
print("API step failed: System.setScreenTimeout: " .. tostring(err))
requestStop()
end-- In system flow, design steps as observe first and act second when the API can affect device state.
local function run_setscreentimeout_step()
local verified = System.setScreenTimeout(60000)
print("Saved timeout verified", verified)
end
local ok, err = pcall(run_setscreentimeout_step)
if not ok then
toast("Step failed")
print(err)
endlocal saved = System.getScreenTimeout()
if saved == nil then error("Screen timeout unavailable") end
assert(System.setScreenTimeout(60000), "Screen timeout write was not verified")
print(System.getScreenTimeout())