Desktop Automation (std.desktop)
The std.desktop module provides API for handling desktop automation using mouse, keyboard etc.
Mouse Automation (std.desktop.mouse)
Section titled “Mouse Automation (std.desktop.mouse)”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 stringdesktop.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 chordsdesktop.keyboard.hotkey("ctrl", "c")desktop.keyboard.hotkey("ctrl", "v")Opening Applications & URLs (desktop.open)
Section titled “Opening Applications & URLs (desktop.open)”Open any website URL, custom browser internal scheme, file, or native application across platforms:
import std.desktop
// Open standard web URLsdesktop.open("https://google.com")
// Open custom browser internal URL schemesdesktop.open("brave://settings")desktop.open("chrome://extensions")
// Open native applications with command-line argumentsdesktop.open("code", ["."])desktop.open("firefox", ["--private-window", "https://news.ycombinator.com"])API Reference
Section titled “API Reference”Desktop Operations
Section titled “Desktop Operations”| Method | Arguments | Returns | Description |
|---|---|---|---|
desktop.open |
target: String, args: [String] = [] |
Bool |
Opens specified URL, browser scheme (e.g. brave://), file, or application with optional arguments. |
Desktop Mouse (std.desktop.mouse)
Section titled “Desktop Mouse (std.desktop.mouse)”| 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). |
Desktop Keyboard (std.desktop.keyboard)
Section titled “Desktop Keyboard (std.desktop.keyboard)”| 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. |
