Skip to main content

Control API

Handles TV remote control.

control.appAlexa

Signatures

appAlexa(n_times \ 1, delay \ 100)

Description

Presses the appAlexa button on the remote control.

control.appDisney

Signatures

appDisney(n_times \ 1, delay \ 100)

Description

Presses the appDisney button on the remote control.

control.appFreevie

Signatures

appFreevie(n_times \ 1, delay \ 100)

Description

Presses the appFreevie button on the remote control.

control.appHulu

Signatures

appHulu(n_times \ 1, delay \ 100)

Description

Presses the appHulu button on the remote control.

control.appNetflix

Signatures

appNetflix(n_times \ 1, delay \ 100)

Description

Presses the appNetflix button on the remote control.

control.appPrime

Signatures

appPrime(n_times \ 1, delay \ 100)

Description

Presses the appPrime button on the remote control.

control.back

Signatures

back(n_times \ 1, delay \ 100)

Description

Presses the back button on the remote control.

control.chNext

Signatures

chNext(n_times \ 1, delay \ 100)

Description

Presses the chNext button on the remote control.

control.chPrev

Signatures

chPrev(n_times \ 1, delay \ 100)

Description

Presses the chPrev button on the remote control.

control.detectPlaybackNative

Signatures

detectPlaybackNative(opts \ [])

Description

Detect video playback using native device capabilities.

Uses the device's native playback detection to determine if video content is currently playing. Optionally taps at coordinates to trigger playback.

Parameters

  • opts (table) - Optional parameters

Options

  • timeout (number) - Maximum time to wait for playback detection in seconds (default: 30)
  • tap (table) - Optional table with x and y coordinates to tap before detection

Returns the elapsed time in seconds when playback is detected. Raises an exception if playback is not detected within the timeout.

Example

-- Simple playback detection
local elapsed = control.detectPlaybackNative({timeout = 10})
print("Playback detected after " .. elapsed .. " seconds")

-- Tap and then detect playback
local elapsed = control.detectPlaybackNative({
timeout = 15,
tap = {x = 960, y = 540}
})

control.down

Signatures

down(n_times \ 1, delay \ 100)

Description

Presses the down button on the remote control.

control.enterText

Signatures

enterText(text)

enterText(arg, text, sleep \ 100)

Description

Enters the provided string of text via a given keyboard, or the system keyboard if one is not provided.

Parameters

  • text (string) - The text to enter using the keyboard

Example

control.enterText("Hello world!")
local kb = keyboard.basic([[
e h l
n m o
]], "h") -- Sets "h" as the initial key. Will set the top left key by default

control.enterText(kb, "hello")

control.enterTextNative

Signatures

enterTextNative(text)

Description

Enter text using the device's native text input method.

Sends text directly to the device using its native text entry capabilities. This bypasses virtual keyboard navigation and types the text directly.

Parameters

  • text (string) - The text string to enter

Example

control.enterTextNative("Hello World")
control.enterTextNative("user@example.com")

control.fastForward

Signatures

fastForward(n_times \ 1, delay \ 100)

Description

Presses the fastForward button on the remote control.

control.guide

Signatures

guide(n_times \ 1, delay \ 100)

Description

Presses the guide button on the remote control.

control.home

Signatures

home(n_times \ 1, delay \ 100)

Description

Presses the home button on the remote control.

control.info

Signatures

info(n_times \ 1, delay \ 100)

Description

Presses the info button on the remote control.

control.input

Signatures

input(n_times \ 1, delay \ 100)

Description

Presses the input button on the remote control.

control.left

Signatures

left(n_times \ 1, delay \ 100)

Description

Presses the left button on the remote control.

control.menu

Signatures

menu(n_times \ 1, delay \ 100)

Description

Presses the menu button on the remote control.

control.mute

Signatures

mute(n_times \ 1, delay \ 100)

Description

Presses the mute button on the remote control.

control.num0

Signatures

num0(n_times \ 1, delay \ 100)

Description

Presses the num0 button on the remote control.

control.num1

Signatures

num1(n_times \ 1, delay \ 100)

Description

Presses the num1 button on the remote control.

control.num2

Signatures

num2(n_times \ 1, delay \ 100)

Description

Presses the num2 button on the remote control.

control.num3

Signatures

num3(n_times \ 1, delay \ 100)

Description

Presses the num3 button on the remote control.

control.num4

Signatures

num4(n_times \ 1, delay \ 100)

Description

Presses the num4 button on the remote control.

control.num5

Signatures

num5(n_times \ 1, delay \ 100)

Description

Presses the num5 button on the remote control.

control.num6

Signatures

num6(n_times \ 1, delay \ 100)

Description

Presses the num6 button on the remote control.

control.num7

Signatures

num7(n_times \ 1, delay \ 100)

Description

Presses the num7 button on the remote control.

control.num8

Signatures

num8(n_times \ 1, delay \ 100)

Description

Presses the num8 button on the remote control.

control.num9

Signatures

num9(n_times \ 1, delay \ 100)

Description

Presses the num9 button on the remote control.

control.ok

Signatures

ok(n_times \ 1, delay \ 100)

Description

Presses the ok button on the remote control.

control.pause

Signatures

pause(n_times \ 1, delay \ 100)

Description

Presses the pause button on the remote control.

control.play

Signatures

play(n_times \ 1, delay \ 100)

Description

Presses the play button on the remote control.

control.playPause

Signatures

playPause(n_times \ 1, delay \ 100)

Description

Presses the playPause button on the remote control.

control.power

Signatures

power(n_times \ 1, delay \ 100)

Description

Presses the power button on the remote control.

control.powerOff

Signatures

powerOff()

Description

Presses the powerOff button on the remote control.

control.powerOn

Signatures

powerOn()

Description

Presses the powerOn button on the remote control.

control.rewind

Signatures

rewind(n_times \ 1, delay \ 100)

Description

Presses the rewind button on the remote control.

control.right

Signatures

right(n_times \ 1, delay \ 100)

Description

Presses the right button on the remote control.

control.sequence

Signatures

sequence(key_sequence, opts \ [])

Description

Executes a sequence of key events provided as a string.

Parameters

  • key_sequence (string) - String of key codes to execute (L=left, R=right, U=up, D=down, E=enter, B=back)
  • opts (table) - Optional parameters

Options

  • :delay (number) - The delay between key presses in milliseconds (default: 100)
  • :confirm (boolean) - Whether to press enter after the sequence (default: false)

Example

control.sequence("LLRR")
control.sequence("UUDDLRLR", delay: 200, confirm: true)
control.sequence("UUDDLRLREB", delay: 200)

control.settings

Signatures

settings(n_times \ 1, delay \ 100)

Description

Presses the settings button on the remote control.

control.swipe

Signatures

swipe(start_x, start_y, end_x, end_y, duration \ 300)

Description

Perform a swipe gesture from one coordinate to another.

Creates a swipe motion from the starting coordinates to the ending coordinates over the specified duration.

Parameters

  • start_x (number) - Normalized starting X coordinate (0 to 1)
  • start_y (number) - Normalized starting Y coordinate (0 to 1)
  • end_x (number) - Normalized ending X coordinate (0 to 1)
  • end_y (number) - Normalized ending Y coordinate (0 to 1)
  • duration (number) - Swipe duration in milliseconds (default: 300)

Example

-- Swipe from left to right
control.swipe(0.1, 0.2, 0.4, 0.2, 500)

-- Quick upward swipe
control.swipe(0.2, 0.4, 0.2, 0.1)

control.swipePoint

Signatures

swipePoint(start_point, end_point, duration \ 300)

Description

Perform a swipe gesture from one coordinate to another.

Coordinates are in range of 0 <= x, y <= 1, representing normalized coordinates relative to the screen size, where (0,0) is the top-left corner and (1,1) is the bottom-right corner.

Parameters

  • start_point ({x, y} or {x=X, y=Y}) - starting point of the swipe gesture, each component is a number in range [0, 1], representing normalized coordinates relative to the screen size.
  • end_point ({x, y} or {x=X, y=Y}) - starting point of the swipe gesture, each component is a number in range [0, 1], representing normalized coordinates relative to the screen size.
  • opts (table) - Optional parameters

Options

  • async - If true, performs the tap asynchronously without blocking (default: false)

Example

-- Swipe from left to right
control.swipePoint({0.1, 0.2}, {0.4, 0.2}, 500)
control.swipePoint({x = 0.1, y = 0.2}, {x = 0.4, y = 0.2}, 500)

-- Quick upward swipe
control.swipePoint({0.2, 0.4}, {0.2, 0.1})
control.swipePoint({x = 0.2, y = 0.4}, {x = 0.2, y = 0.1})

control.tap

Signatures

tap(x, y, opts \ [])

Description

Perform a tap gesture at the specified screen coordinates.

Coordinates are in range of 0 <= x, y <= 1, representing normalized coordinates relative to the screen size, where (0,0) is the top-left corner and (1,1) is the bottom-right corner.

Parameters

  • x (number) - normalized X coordinate (0 to 1)
  • y (number) - normalized Y coordinate (0 to 1)
  • opts (table) - Optional parameters

Options

  • async - If true, performs the tap asynchronously without blocking (default: false)

Example

-- Tap at coordinates at 50%, 50% of the screen
control.tap(0.5, 0.5)

-- Async tap
control.tap(0.5, 0.5, {async = true})

control.tapPoint

Signatures

tapPoint(point, opts \ [])

Description

Perform a tap gesture at the specified screen coordinates given as a point.

Coordinates are in range of 0 <= x, y <= 1, representing normalized coordinates relative to the screen size, where (0,0) is the top-left corner and (1,1) is the bottom-right corner.

Parameters

  • point ({x, y} or {x=X, y=Y}) - point to tap on the screen, each component is a number in range [0, 1], representing normalized coordinates relative to the screen size.
  • opts (table) - Optional parameters

Options

  • async - If true, performs the tap asynchronously without blocking (default: false)

Example

-- Tap at coordinates at 50%, 50% of the screen
control.tapPoint({0.5, 0.5})
control.tapPoint({x = 0.5, y = 0.5})

-- Async tap
control.tapPoint({x = 0.5, y = 0.5}, {async = true})

control.up

Signatures

up(n_times \ 1, delay \ 100)

Description

Presses the up button on the remote control.

control.volumeDown

Signatures

volumeDown(n_times \ 1, delay \ 100)

Description

Presses the volumeDown button on the remote control.

control.volumeUp

Signatures

volumeUp(n_times \ 1, delay \ 100)

Description

Presses the volumeUp button on the remote control.