Function Reference
Complete reference for all built-in Macroni functions.
OCR Functions
@capture_region(key, overwrite_cache)
Interactive region capture with caching.
Parameters:
key(string): Unique identifier for cachingoverwrite_cache(boolean):trueto force recapture,falseto use cache
Returns: (x1, y1, x2, y2) - Top-left and bottom-right coordinates
Cache: Saved to regions_cache.json
Example
Interactive Flow
- Hover mouse over top-left corner → Press Enter
- Hover mouse over bottom-right corner → Press Enter
@ocr_find_text(region, min_conf, filter, upscale)
Find text on screen using OCR (EasyOCR).
Parameters:
region(tuple or null):(x1, y1, x2, y2)from@capture_region()ornullfor full screenmin_conf(float): Confidence threshold 0.0-1.0 (0.8 recommended)filter(string or null): Case-insensitive substring to search for, ornullfor all textupscale(float): Scaling factor -1.0= default,0.5= faster,2.0= tiny text
Returns: List of (text, confidence, [[x1,y1], [x2,y2], [x3,y3], [x4,y4]])
- Bounding box has 4 corners in screen coordinates
- Sorted by confidence (highest first)
Example
GPU Acceleration
Edit ocr.py line 10: reader = easyocr.Reader(['en'], gpu=True) (Requires CUDA)
Mouse Functions
@mouse_move(x, y, speed, human_like)
Move mouse cursor to coordinates.
Parameters:
x(int): X coordinatey(int): Y coordinatespeed(int): Movement speed in pixels/secondhuman_like(boolean):truefor curved path,falsefor straight line
Returns: None
@left_click()
Perform left mouse click at current cursor position.
Parameters: None
Returns: None
@mouse_position()
Get current mouse cursor position.
Parameters: None
Returns: (x, y) - Current cursor coordinates
Keyboard Functions
@press_and_release(delay_ms, ...keys)
Press and release keyboard keys in sequence.
Parameters:
delay_ms(int): Delay between press and release in milliseconds...keys(strings): Variable number of key names (e.g., "ctrl", "c", "shift", "a")
Returns: None
Example
@send_input(type, key, action)
Low-level input control.
Parameters:
type(string):"keyboard"or"mouse"key(string): Key or button nameaction(string):"press","release", or"click"
Returns: None
Template Matching
@set_template_dir(path)
Set directory containing template images.
Parameters:
path(string): Path to templates directory
Returns: None
@find_template(name) / @find_template(name, left, top, width, height)
Find first template match on screen.
Parameters:
name(string): Template name (subdirectory in templates folder)left, top, width, height(optional ints): Search region bounds
Returns: (x, y) coordinates of center, or (null, null) if not found
Example
@find_templates(name, top_k)
Find multiple template matches.
Parameters:
name(string): Template nametop_k(int): Maximum number of matches to return
Returns: Tuple of (x, y) coordinate pairs
Screen Functions
@get_coordinates(label, use_cache)
Interactive coordinate capture.
Parameters:
label(string): Unique identifier for cachinguse_cache(boolean):trueto use cache,falseto recapture
Returns: (x, y) coordinates
Cache: Saved to coordinates_cache.json
@get_pixel_at(x, y)
Get RGB color at specific pixel.
Parameters:
x(int): X coordinatey(int): Y coordinate
Returns: (r, g, b) - RGB values (0-255)
@get_pixel_color(alias, use_cache)
Interactive color capture.
Parameters:
alias(string): Unique identifier for cachinguse_cache(boolean):trueto use cache,falseto recapture
Returns: (r, g, b) - RGB values
Cache: Saved to pixel_colors_cache.json
@check_pixel_color(x, y, radius, r, g, b, tolerance)
Check if pixel color matches within tolerance.
Parameters:
x, y(int): Coordinatesradius(int): Search radius in pixelsr, g, b(int): Expected RGB values (0-255)tolerance(int): Color difference tolerance (0-255)
Returns: true if match found, false otherwise
Example
Timing Functions
@wait(ms) / @wait(min, max)
Pause execution.
Parameters:
ms(int): Wait time in milliseconds (deterministic)min, max(ints): Random wait between min and max milliseconds
Returns: Actual wait time in milliseconds
@time()
Get current Unix timestamp.
Parameters: None
Returns: Float timestamp in seconds
Example
Random Functions
@rand(min, max)
Generate random float.
Parameters:
min(float): Minimum value (inclusive)max(float): Maximum value (inclusive)
Returns: Random float in range
@rand_i(min, max)
Generate random integer.
Parameters:
min(int): Minimum value (inclusive)max(int): Maximum value (inclusive)
Returns: Random integer in range
Recording Functions
@record(name, start_btn, stop_btn)
Record mouse and keyboard actions.
Parameters:
name(string): Recording identifierstart_btn(optional string): Key to start recording (default:"space")stop_btn(optional string): Key to stop recording (default:"esc")
Returns: None
Cache: Saved to recordings_cache.json
Example
@playback(name, stop_btn)
Replay recorded actions.
Parameters:
name(string): Recording identifierstop_btn(optional string): Key to stop playback (default:"esc")
Returns: None
@recording_exists(name)
Check if recording exists.
Parameters:
name(string): Recording identifier
Returns: true if exists, false otherwise
List Functions
@len(collection)
Get length of collection.
Parameters:
collection(list, tuple, or string): Collection to measure
Returns: Integer length
@append(list, item)
Add item to end of list (modifies in place).
Parameters:
list(list): List to modifyitem(any): Item to append
Returns: None
@pop(list) / @pop(list, index)
Remove and return item from list.
Parameters:
list(list): List to modifyindex(optional int): Index to remove (default: -1, last item)
Returns: Removed item
Example
@shuffle(collection)
Return shuffled copy of collection.
Parameters:
collection(list or tuple): Collection to shuffle
Returns: New shuffled list
Example
@swap(list, i, j)
Swap two elements in a list.
Parameters:
list(list): List to modifyi(int): First indexj(int): Second index
Returns: None
@copy(collection)
Create shallow copy of collection.
Parameters:
collection(list or tuple): Collection to copy
Returns: New collection with same elements
Example
Type Checking
@is_int(val) / @is_float(val) / @is_str(val) / @is_list(val) / @is_tuple(val)
Check value type.
Parameters:
val(any): Value to check
Returns: true if value matches type, false otherwise
Example
Type Conversion
@int(val) / @float(val) / @str(val)
Convert value to specified type.
Parameters:
val(any): Value to convert
Returns: Converted value
Utility Functions
@print(arg1, arg2, ...)
Print values to console.
Parameters:
...args(any): Variable number of arguments to print
Returns: None
Enjoying Macroni? ⭐ Give us a star on GitHub