Home

Awesome

vrobot

Work in progress. Only Windows is supported.

Basic desktop automation functions for V lang. PRs welcome :)

Plans

All ideas are welcome!

Example

import vrobot

// Print mouse position
pos := vrobot.mouse_pos()
println('Mouse position: $pos.x, $pos.y')

// Print pixel color at (100, 100)
color := vrobot.pixel_color(100, 100)
println('Pixel color is: ($color.r, $color.g, $color.b)')

// Print screen resolution
screen := vrobot.screen_size()
println('Screen size: $screen.width, $screen.height')

// Moves mouse twice and returns to starting position
vrobot.move_mouse(pos.x + 100, pos.y + 100)
vrobot.move_mouse_smooth_rel(-100, -100, 500, 'linear')

// Drags from (100, 100) to (150, 150) with left click
vrobot.move_mouse(100, 100)
vrobot.drag(150, 150)

🖱️ Valid mouse buttons are: left, right, middle

Functions

Mouse

mouse_pos() { x, y int }

Returns struct with current mouse position.

click(button string)

Clicks with mouse.

double_click(button string)

Double clicks.

drag(x, y int)

Drags mouse (left) to specified position.

drag_rel(offset_x, offset_y int)

Drags mouse (left) relative to current position.

move_mouse(x, y int)

Moves mouse to x, y.

move_mouse_rel(offset_x, offset_y)

Moves mouse relative to current position.

move_mouse_smooth(x, y, duration_ms int, tween string)

Moves mouse smoothly to dest_x, dest_y in duration_ms.

See list of available tweens below.

move_mouse_smooth_rel(offset_x, offset_y, duration_ms int, tween string)

Moves mouse smoothly, relative to current position in duration_ms.

See list of available tweens below.

Screen

screen_size() { width, height, int }

Returns screen size in pixels.

pixel_color(x, y int) { r, g, b int }

Returns pixel color at x, y.

Available mouse tweens

You can preview tweens here: https://easings.net/

Credits

Thanks to the amazing team at @vlang and their Discord channel.

Inspired by robotgo and pyautogui.