Giter Club home page Giter Club logo

vrobot's Introduction

vrobot

Work in progress. Only Windows is supported.

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

Plans

  • Add more mouse easing functions, currently it only has linear
  • Screen related functions
    • screen_size()
    • pixel_color()
    • locate_on_screen() For colors and images
  • Keyboard simulation and hooks
  • Linux support, not priority currently

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/

  • linear
  • ease_in_quad
  • ease_out_quad
  • ease_in_out_quad
  • ease_in_cubic
  • ease_out_cubic
  • ease_in_out_cubic
  • ease_in_quart
  • ease_out_quart
  • ease_in_out_quart
  • ease_in_quint
  • ease_out_quint
  • ease_in_out_quint
  • ease_in_sine
  • ease_out_sine
  • ease_in_out_sine
  • ease_in_expo
  • ease_out_expo
  • ease_in_out_expo
  • ease_in_circ
  • ease_out_circ
  • ease_in_out_circ
  • ease_in_elastic
  • ease_out_elastic
  • ease_in_out_elastic
  • ease_in_back
  • ease_out_back
  • ease_in_out_back
  • ease_in_bounce
  • ease_out_bounce
  • ease_in_out_bounce

Credits

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

Inspired by robotgo and pyautogui.

vrobot's People

Contributors

eioo avatar victorem4ever avatar

Stargazers

快乐两小时 avatar chenfyun avatar André Luiz avatar  avatar Milad avatar  avatar ylluminate avatar  avatar Stuart Gilliland  avatar levantocode avatar Daniel Däschle avatar Imaginary Stargazer avatar Giorgio Bellisario avatar  avatar  avatar  avatar zztkm avatar Dante Mendoza avatar z112 avatar Fabian avatar lydiandy avatar Steve Phillips avatar Alloys Mila avatar  avatar  avatar Elliot Gerchak avatar  avatar Fidele K avatar Marc Gutenberger avatar  avatar whiter001 avatar  avatar  avatar Aarmn the limitless avatar  avatar João Paulo de C. Lima avatar Abu Ghurab avatar  avatar Bastian Buck avatar JohnsonB avatar Jonah Matteson avatar TemplarUndead avatar  avatar  avatar Prem avatar Abdullah Atta avatar  avatar mark05E avatar icew4ll avatar Carter Gale avatar Nob avatar Delyan Angelov avatar

Watchers

James Cloos avatar  avatar Fidele K avatar Giorgio Bellisario avatar

vrobot's Issues

Missing ability to simulate typing

It should be possible to simulate keyboard input.
It should also be possible to type special characters like • that are not immediately available on the keyboard.
Also, pressing keys in combination should be possible, like Ctrl+Alt+J.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.