robotscript

package module
v0.0.0-...-cafa771 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2018 License: MIT Imports: 10 Imported by: 0

README

RobotScript

Build Status

RobotScript is a scriptable, cross-platform desktop automation tool.

Installation

Statically linked binaries will be available for download here once the project is functional. In the meantime, feel free to build it yourself.

Usage

robotscript script.yml

Script Reference

Script files are written in YAML format. The commands are fairly self-explanatory/self-documenting. Here is a comprehensive example:

commands:
  - mouse:                 # command: moves the mouse cursor
      x: 200               # required: integer: x pixel
      y: 200               # required: integer: y pixel
      relative: false      # optional: boolean: moves cursor relative to original position
      smooth: true         # optional: boolean: moves cursor smoothly instead of instantly
  - click:                 # command: clicks a mouse button
      button: left         # required: string: mouse button (left, right, or center)
  - keypress:              # command: presses a key
      key: c               # required: string: key to be pressed (case insensitive)
      mods:                # optional: list<string>: modifier keys
        - shift            # note: this must be a list, even if there's only one
  - sleep:                 # command: does nothing for some time
      seconds: 1           # required: integer: seconds to wait
  - type:                  # command: types some text
      text: hello, world   # required: string: text to be typed
  - exec:                  # command: executes a program
      program: stat        # required: string: program to run
      args: /tmp/fakefile  # optional: string: command line arguments (not a list)

For a key naming reference, see here.

Acknowledgements

The following open source libraries have made my life much easier:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	Execute() // Execute executes the command.
}

Command defines the Execute function which any command must implement.

func NewCommand

func NewCommand(name string, options map[string]interface{}) (Command, error)

NewCommand creates a new command from an options map.

type ExecCommand

type ExecCommand struct {
	Program string
	Args    string
}

ExecCommand executes a system command.

func NewExecCommand

func NewExecCommand(options map[string]interface{}) (*ExecCommand, error)

NewExecCommand creates a new ExecCommand from an options map.

func (*ExecCommand) Execute

func (c *ExecCommand) Execute()

Execute executes the command.

type KeyPressCommand

type KeyPressCommand struct {
	Key  string // https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
	Mods []string
}

KeyPressCommand presses a key.

func NewKeyPressCommand

func NewKeyPressCommand(options map[string]interface{}) (*KeyPressCommand, error)

NewKeyPressCommand creates a new KeyPressCommand from an options map.

func (*KeyPressCommand) Execute

func (c *KeyPressCommand) Execute()

Execute executes the command.

type MouseClickCommand

type MouseClickCommand struct {
	Button string // "left", "center", or "right".
}

MouseClickCommand clicks the mouse.

func NewMouseClickCommand

func NewMouseClickCommand(options map[string]interface{}) (*MouseClickCommand, error)

NewMouseClickCommand creates a new MouseClickCommand from an options map.

func (*MouseClickCommand) Execute

func (c *MouseClickCommand) Execute()

Execute executes the command.

type MouseMoveCommand

type MouseMoveCommand struct {
	X, Y     int // Pixels.
	Relative bool
	Smooth   bool
}

MouseMoveCommand moves the mouse.

func NewMouseMoveCommand

func NewMouseMoveCommand(options map[string]interface{}) (*MouseMoveCommand, error)

NewMouseMoveCommand creates a new MouseMoveCommand from an options map.

func (*MouseMoveCommand) Execute

func (c *MouseMoveCommand) Execute()

Execute executes the command.

type Script

type Script struct {
	Commands []Command
}

Script is a sequence of commands to execute.

func NewScript

func NewScript(filename string) (*Script, error)

NewScript parses the YAML file at filename into a new Script.

func (*Script) Execute

func (s *Script) Execute()

Execute executes each script command.

type SleepCommand

type SleepCommand struct {
	Seconds int
}

SleepCommand does nothing for some amount of time.

func NewSleepCommand

func NewSleepCommand(options map[string]interface{}) (*SleepCommand, error)

NewSleepCommand creates a new SleepCommand from an options map.

func (*SleepCommand) Execute

func (c *SleepCommand) Execute()

Execute executes the command.

type TypeCommand

type TypeCommand struct {
	Text string
}

TypeCommand types some text.

func NewTypeCommand

func NewTypeCommand(options map[string]interface{}) (*TypeCommand, error)

NewTypeCommand creates a new TypeCommand from an options map.

func (*TypeCommand) Execute

func (c *TypeCommand) Execute()

Execute executes the command.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL