Skip to content

Hardware Telemetry & Desktop Automation (std.hardware, std.desktop)

Flame provides deep hardware inspection and cross-platform desktop automation directly out of the box. Execute GUI scripts and inspect system telemetry cleanly at the top level without requiring an entry point function or external automation tools.


Query live system CPU utilization, hardware clock frequencies, and RAM availability:

import std.hardware
// Display host kernel and system discovery metadata
println(hardware.discover())
// Inspect active RAM statistics (in bytes)
let mem = hardware.memory()
println($"RAM Total: {mem.total} bytes | Free: {mem.free} bytes")
// Inspect individual CPU processor core telemetry
let cores = hardware.cpu()
println($"Total CPU Cores Detected: {cores.len()}")
for core in cores {
println($"[{core.name}] ({core.brand}): Usage {core.usage}% at {core.frequency} MHz")
}

Programmatically control mouse pointer coordinates and simulate button clicks:

import std.desktop
// Move mouse cursor to absolute screen coordinates (X, Y)
desktop.mouse.move(500, 300)
// Simulate mouse button clicks ("left", "right", or "middle")
desktop.mouse.click("left")
desktop.mouse.click("right")

Keyboard Input & Hotkeys (std.desktop.keyboard)

Section titled “Keyboard Input & Hotkeys (std.desktop.keyboard)”

Type text strings, trigger individual keystrokes, or press multi-key shortcut chords:

import std.desktop
// Simulate typing a full text string
desktop.keyboard.write("Hello from automated Flame!")
// Tap individual keys (e.g., "enter", "escape", "tab", "backspace", "up", "down")
desktop.keyboard.key("enter")
desktop.keyboard.key("tab")
// Hold and release key states explicitly ("click", "press", or "release")
desktop.keyboard.key("shift", "press")
desktop.keyboard.key("a", "click")
desktop.keyboard.key("shift", "release")
// Execute simultaneously pressed hotkey chords
desktop.keyboard.hotkey("ctrl", "c")
desktop.keyboard.hotkey("ctrl", "v")

Method Arguments Returns Description
hardware.cpu None Tuple<Formula> Returns a list of formulas containing { name, usage, brand, frequency } per CPU core.
hardware.memory None Formula Returns a formula containing system memory statistics in bytes: { total, used, free, available }.
hardware.discover None String Returns a human-readable discovery summary string containing system name, OS version, and kernel version.
Method Arguments Returns Description
desktop.mouse.move x: Int, y: Int Nil Moves the system cursor pointer instantly to absolute pixel coordinates $(X, Y)$.
desktop.mouse.click button: String? Nil Simulates a button click. Option values: "left", "right", or "middle" (defaults to "left" if omitted).
Method Arguments Returns Description
desktop.keyboard.write text: String Nil Simulates character typing for an entire UTF-8 string sequentially.
desktop.keyboard.key key: String, action: String? Nil Performs key action ("click", "press", or "release") on specified key name. Defaults to "click".
desktop.keyboard.hotkey key1: String, key2: String, ... Nil Presses all specified keys simultaneously in order, then releases them in reverse order.