Input

Simulate mouse and keyboard input in the Roblox window.

20 functionssUNC 100%Lynx 0.747

Use these functions to move the mouse, send key presses and control input to the Roblox window.

Window and cursor state

iswindowactive

iswindowactive(): boolean

iswindowactive returns whether the Roblox window is currently active.

Also available as isrbxactive and isgameactive.

Returns

boolean

Whether Roblox is active.

setwindowtitle

setwindowtitle(title: string): ()

setwindowtitle changes the Roblox window title.

Parameters

titlestring
UTF-8 window title. An empty string is allowed.

Returns

()

No return values.

Example

local original = getwindowtitle()
setwindowtitle("Lynx example")
setwindowtitle(original)

getwindowtitle

getwindowtitle(): string

getwindowtitle reads the current Roblox window title.

Returns

string

Current title encoded as UTF-8.

Example

print(getwindowtitle())

setwindowicon

setwindowicon(path: string? = nil): ()

setwindowicon changes both Roblox window icons using a workspace .ico file, or restores the original icons.

Parameters

pathstring?
Optional.Workspace-relative path to an existing .ico file; omit or pass nil to restore the original icons. Default nil.

Returns

()

No return values.

Example

setwindowicon("my-icon.ico") -- Existing workspace file
setwindowicon() -- Restore the original icons

getmousestate

getmousestate(): boolean

getmousestate returns whether the Lynx mouse cursor is visible.

Returns

boolean

Whether the Lynx mouse cursor is visible.

setmousestate

setmousestate(enabled: boolean): ()

setmousestate shows or hides the Lynx mouse cursor.

Parameters

enabledboolean
Whether to enable this setting.

Returns

()

This function does not return a value.

Keyboard

Output key functions accept a Windows virtual-key integer from 1 through 255 or a supported Enum.KeyCode. State queries accept only the numeric virtual-key form. Unsupported enum mappings and invalid codes raise an argument error.

keypress

keypress(key: number | Enum.KeyCode): ()

keypress presses the specified key without releasing it.

Parameters

keynumber | Enum.KeyCode
The key to press, release or inspect.

Returns

()

This function does not return a value.

keyrelease

keyrelease(key: number | Enum.KeyCode): ()

keyrelease releases the specified key.

Parameters

keynumber | Enum.KeyCode
The key to press, release or inspect.

Returns

()

This function does not return a value.

keyclick

keyclick(key: number | Enum.KeyCode): ()

keyclick presses and releases the specified key.

Also available as keytap.

Parameters

keynumber | Enum.KeyCode
The key to press, release or inspect.

Returns

()

This function does not return a value.

iskeydown

iskeydown(key: number): boolean

iskeydown returns whether the specified key is held down.

Parameters

keynumber
The key to press, release or inspect.

Returns

boolean

Whether the key is currently pressed.

iskeytoggled

iskeytoggled(key: number): boolean

iskeytoggled returns whether the specified toggle key is enabled.

Parameters

keynumber
The key to press, release or inspect.

Returns

boolean

Whether the toggle key is enabled.

Mouse buttons

Button and scroll events are sent only while the Roblox window is active.

mouse1click

mouse1click(): ()

mouse1click presses and releases the left mouse button.

Returns

()

This function does not return a value.

mouse2click

mouse2click(): ()

mouse2click presses and releases the right mouse button.

Returns

()

This function does not return a value.

mouse1press

mouse1press([x: number, y: number]): ()

mouse1press presses the left mouse button.

Parameters

xnumber?
Optional.The horizontal position in Roblox client coordinates.
ynumber?
Optional.The vertical position in Roblox client coordinates.

Returns

()

This function does not return a value.

mouse1release

mouse1release([x: number, y: number]): ()

mouse1release releases the left mouse button.

Parameters

xnumber?
Optional.The horizontal position in Roblox client coordinates.
ynumber?
Optional.The vertical position in Roblox client coordinates.

Returns

()

This function does not return a value.

mouse2press

mouse2press([x: number, y: number]): ()

mouse2press presses the right mouse button.

Parameters

xnumber?
Optional.The horizontal position in Roblox client coordinates.
ynumber?
Optional.The vertical position in Roblox client coordinates.

Returns

()

This function does not return a value.

mouse2release

mouse2release([x: number, y: number]): ()

mouse2release releases the right mouse button.

Parameters

xnumber?
Optional.The horizontal position in Roblox client coordinates.
ynumber?
Optional.The vertical position in Roblox client coordinates.

Returns

()

This function does not return a value.

Mouse movement

mousemoveabs

mousemoveabs(x: number, y: number, internal: any?): ()

mousemoveabs moves the mouse to a position within the Roblox window.

Parameters

xnumber
The horizontal position in Roblox client coordinates.
ynumber
The vertical position in Roblox client coordinates.
internalany?
Optional.When supplied and not nil, a truthy value selects cursor-only movement and false selects desktop movement. Omit or pass nil for automatic selection.

Returns

()

This function does not return a value.

mousemoverel

mousemoverel(dx: number, dy: number, internal: any?): ()

mousemoverel moves the mouse by the specified horizontal and vertical distances.

Parameters

dxnumber
The horizontal distance in pixels.
dynumber
The vertical distance in pixels.
internalany?
Optional.When supplied and not nil, a truthy value selects cursor-only movement and false selects desktop movement. Omit or pass nil for automatic selection.

Returns

()

This function does not return a value.

mousescroll

mousescroll(delta: number | boolean, [x: number, y: number]): ()

mousescroll scrolls the mouse wheel.

Parameters

deltanumber | boolean
The wheel distance, or true for one forward step and false for one backward step.
xnumber?
Optional.The horizontal position in Roblox client coordinates.
ynumber?
Optional.The vertical position in Roblox client coordinates.

Returns

()

This function does not return a value.

if iswindowactive() then
keyclick(Enum.KeyCode.Space)
end
mousemoveabs(100, 100, true)