gotomation

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

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

Go to latest
Published: Apr 21, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

Gotomation
============

Automation library like ``java.awt.Robot``.

Document
----------

https://godoc.org/github.com/shibukawa/gotomation

License
--------

Apache-2

Known Issue
-----------

* Mouse coursor moving is not working on VirtualBox host OS with mouse cursor integration.
* Windows: mouse cursor moving is not working (I tested on Windows 10 Pro on VirtualBox)
* X11: String typing is not implemented. In future, I will add this only for cgo environment.
  XCB (and xgb - golang version) doesn't support ``XStringToKeysym()`` equivalent function.

Thanks
------

* https://github.com/BurntSushi/xgb

  It uses ``xgb`` for X11 environment.

* https://github.com/go-vgo/robotgo

  This code is inspired by robotogo. I rewrite into pure go, add utf-8 support etc as much as possible.

Documentation

Overview

Package gotomation is cross-platform system automation library.

Index

Constants

View Source
const (
	SHIFT   KeyModifier = 0x0001
	ALT                 = 0x0002
	CONTROL             = 0x0004
	META                = 0x0008
	WIN                 = META
	COMMAND             = META
)
View Source
const (
	VK_NOT_A_KEY KeyCode = 9999

	VK_A            = 30
	VK_S            = 31
	VK_D            = 32
	VK_F            = 33
	VK_H            = 35
	VK_G            = 34
	VK_Z            = 44
	VK_X            = 45
	VK_C            = 46
	VK_V            = 47
	VK_B            = 48
	VK_Q            = 16
	VK_W            = 17
	VK_E            = 18
	VK_R            = 19
	VK_Y            = 21
	VK_T            = 20
	VK_1            = 2
	VK_2            = 3
	VK_3            = 4
	VK_4            = 5
	VK_6            = 7
	VK_5            = 6
	VK_EQUAL        = 13
	VK_9            = 10
	VK_7            = 8
	VK_MINUS        = 12
	VK_8            = 9
	VK_0            = 11
	VK_RIGHTBRACKET = 27
	VK_O            = 24
	VK_U            = 22
	VK_LEFTBRACKET  = 26
	VK_I            = 23
	VK_P            = 25
	VK_L            = 38
	VK_J            = 36
	VK_QUOTE        = 40
	VK_K            = 37
	VK_SEMICOLON    = 39
	VK_BACKSLASH    = 43
	VK_COMMA        = 51
	VK_SLASH        = 53
	VK_N            = 49
	VK_M            = 50
	VK_PERIOD       = 52
	VK_GRAVE        = 41

	VK_BACKSPACE = 14
	VK_DELETE    = 111
	VK_RETURN    = 28
	VK_TAB       = 15
	VK_ESCAPE    = 1
	VK_UP        = 103
	VK_DOWN      = 108
	VK_RIGHT     = 106
	VK_LEFT      = 105
	VK_HOME      = 102
	VK_END       = 107
	VK_PAGEUP    = 104
	VK_PAGEDOWN  = 109
	VK_F1        = 59 // VK_F1
	VK_F2        = 60 // VK_F2
	VK_F3        = 61 // VK_F3
	VK_F4        = 62 // VK_F4
	VK_F5        = 63 // VK_F5
	VK_F6        = 64 // VK_F6
	VK_F7        = 65 // VK_F7
	VK_F8        = 66 // VK_F8
	VK_F9        = 67 // VK_F9
	VK_F10       = 68 // VK_F10
	VK_F11       = 87 // VK_F11
	VK_F12       = 88 // VK_F12
	VK_F13       = VK_NOT_A_KEY
	VK_F14       = VK_NOT_A_KEY
	VK_F15       = VK_NOT_A_KEY
	VK_F16       = VK_NOT_A_KEY
	VK_F17       = VK_NOT_A_KEY
	VK_F18       = VK_NOT_A_KEY
	VK_F19       = VK_NOT_A_KEY
	VK_F20       = VK_NOT_A_KEY
	VK_ALT       = 56
	VK_LALT      = 56
	VK_RALT      = 100
	VK_CONTROL   = 29
	VK_LCONTROL  = 29
	VK_RCONTROL  = 97
	VK_SHIFT     = 42
	VK_LSHIFT    = 42
	VK_RSHIFT    = 54
	VK_LMENU     = VK_NOT_A_KEY
	VK_RMENU     = VK_NOT_A_KEY
	VK_LWIN      = VK_NOT_A_KEY
	VK_RWIN      = VK_NOT_A_KEY
	VK_META      = VK_NOT_A_KEY
	VK_LMETA     = VK_NOT_A_KEY
	VK_RMETA     = VK_NOT_A_KEY
	VK_LCOMMAND  = VK_NOT_A_KEY
	VK_RCOMMAND  = VK_NOT_A_KEY
	VK_CAPSLOCK  = 58
	VK_SPACE     = 57
	VK_INSERT    = 100
	VK_SNAPSHOT  = VK_NOT_A_KEY
	VK_NUMLOCK   = 69
	VK_SCROLL    = 70

	VK_NUMPAD_0       = VK_NOT_A_KEY
	VK_NUMPAD_1       = 79
	VK_NUMPAD_2       = 80
	VK_NUMPAD_3       = 81
	VK_NUMPAD_4       = 75
	VK_NUMPAD_5       = 76
	VK_NUMPAD_6       = 77
	VK_NUMPAD_7       = 71
	VK_NUMPAD_8       = 72
	VK_NUMPAD_9       = 73
	VK_NUMPAD_DECIMAL = VK_NOT_A_KEY
	VK_NUMPAD_PLUS    = 78
	VK_NUMPAD_MINUS   = 74
	VK_NUMPAD_MUL     = 55
	VK_NUMPAD_DIV     = 98
	VK_NUMPAD_CLEAR   = VK_NOT_A_KEY
	VK_NUMPAD_ENTER   = 96
	VK_NUMPAD_EQUAL   = VK_NOT_A_KEY

	VK_AUDIO_VOLUME_MUTE = VK_NOT_A_KEY
	VK_AUDIO_VOLUME_DOWN = VK_NOT_A_KEY
	VK_AUDIO_VOLUME_UP   = VK_NOT_A_KEY
	VK_AUDIO_PLAY        = VK_NOT_A_KEY
	VK_AUDIO_STOP        = VK_NOT_A_KEY
	VK_AUDIO_PREV        = VK_NOT_A_KEY
	VK_AUDIO_NEXT        = VK_NOT_A_KEY

	VK_LIGHTS_MON_UP     = VK_NOT_A_KEY
	VK_LIGHTS_MON_DOWN   = VK_NOT_A_KEY
	VK_LIGHTS_KBD_TOGGLE = VK_NOT_A_KEY
	VK_LIGHTS_KBD_UP     = VK_NOT_A_KEY
	VK_LIGHTS_KBD_DOWN   = VK_NOT_A_KEY

	VK_YEN          = VK_NOT_A_KEY
	VK_UNDERSCORE   = VK_NOT_A_KEY
	VK_KEYPAD_COMMA = VK_NOT_A_KEY
	VK_EISU         = VK_NOT_A_KEY
	VK_KANA         = VK_NOT_A_KEY
	VK_HANGUL       = VK_NOT_A_KEY
	VK_JUNJA        = VK_NOT_A_KEY
	VK_FINAL        = VK_NOT_A_KEY
)
View Source
const (
	MouseLeft   MouseButton = 1
	MouseCenter             = 2
	MouseRight              = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyCode

type KeyCode uint16

type KeyModifier

type KeyModifier uint16

type Keyboard

type Keyboard struct {
	// contains filtered or unexported fields
}

func (*Keyboard) KeyDown

func (k *Keyboard) KeyDown(code KeyCode, modifiers ...KeyModifier) error

func (*Keyboard) KeyPress

func (k *Keyboard) KeyPress(code KeyCode, modifiers ...KeyModifier) error

func (*Keyboard) KeyUp

func (k *Keyboard) KeyUp(code KeyCode, modifiers ...KeyModifier) error

func (*Keyboard) SetTypeSpeed

func (k *Keyboard) SetTypeSpeed(charPerMin int)

func (*Keyboard) Type

func (k *Keyboard) Type(str string) error

func (*Keyboard) TypeQuickly

func (k *Keyboard) TypeQuickly(str string) error

func (*Keyboard) TypeSpeed

func (k *Keyboard) TypeSpeed() int

type Mouse

type Mouse struct {
	// contains filtered or unexported fields
}

func (*Mouse) Click

func (m *Mouse) Click() error

func (*Mouse) ClickWith

func (m *Mouse) ClickWith(button MouseButton) error

func (*Mouse) DoubleClick

func (m *Mouse) DoubleClick() error

func (*Mouse) DoubleClickWith

func (m *Mouse) DoubleClickWith(button MouseButton) error

func (*Mouse) Drag

func (m *Mouse) Drag(x, y int) error

func (*Mouse) DragWith

func (m *Mouse) DragWith(button MouseButton, x, y int) error

func (*Mouse) GetPosition

func (m *Mouse) GetPosition() (x, y int)

func (*Mouse) Move

func (m *Mouse) Move(x, y int, duration time.Duration) error

MoveMouse moves mouse cursor with Robert Penner's Easing Function: easeInOutCubic

http://robertpenner.com/easing/

func (*Mouse) MoveQuickly

func (m *Mouse) MoveQuickly(x, y int) error

func (*Mouse) Scroll

func (m *Mouse) Scroll(x, y int, duration time.Duration) error

func (*Mouse) ScrollQuickly

func (m *Mouse) ScrollQuickly(x, y int) error

type MouseButton

type MouseButton int

type Screen

type Screen struct {
	// contains filtered or unexported fields
}

func GetMainScreen

func GetMainScreen() (*Screen, error)

func GetScreen

func GetScreen(id int) (*Screen, error)

func (*Screen) Capture

func (s *Screen) Capture() (image.Image, error)

func (*Screen) CaptureRegion

func (s *Screen) CaptureRegion(rect image.Rectangle) (image.Image, error)

func (*Screen) Close

func (s *Screen) Close()

func (*Screen) H

func (s *Screen) H() int

func (*Screen) ID

func (s *Screen) ID() int

func (*Screen) Keyboard

func (s *Screen) Keyboard() *Keyboard

func (*Screen) Mouse

func (s *Screen) Mouse() *Mouse

func (*Screen) RawCapture

func (s *Screen) RawCapture() (image.Image, error)

func (*Screen) RawCaptureRegion

func (s *Screen) RawCaptureRegion(rect image.Rectangle) (image.Image, error)

func (*Screen) W

func (s *Screen) W() int

func (*Screen) X

func (s *Screen) X() int

func (*Screen) Y

func (s *Screen) Y() int

Jump to

Keyboard shortcuts

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