Documentation ¶
Overview ¶
Package robotgo Go native cross-platform system automation.
Please make sure Golang, GCC is installed correctly before installing RobotGo;
See Requirements:
https://github.com/go-vgo/robotgo#requirements
Installation:
go get -u github.com/go-vgo/robotgo
Index ¶
- Constants
- Variables
- func ActiveName(name string) error
- func ActivePID(pid int32, args ...int) error
- func ActivePIDC(pid int32, args ...int) error
- func AddEvent(key string) bool
- func AddEvents(key string, arr ...string) bool
- func AddMouse(btn string, x ...int16) bool
- func AddMousePos(x, y int16) bool
- func CharCodeAt(s string, n int) rune
- func CheckMouse(btn string) C.MMMouseButton
- func Click(args ...interface{})
- func CloseWindow(args ...int32)
- func Drag(x, y int, args ...string)
- func DragMouse(x, y int, args ...string)
- func DragSmooth(x, y int, args ...interface{})
- func End()
- func EventEnd()
- func EventHook(when uint8, keysPressed []string, callback func(hook.Event))
- func EventProcess(events chan hook.Event) chan bool
- func EventStart() chan hook.Event
- func FindIds(name string) ([]int, error)
- func FindName(pid int) (string, error)
- func FindNames() ([]string, error)
- func FindPath(pid int) (string, error)
- func GetActive() C.MData
- func GetBHandle() int
- func GetBounds(pid int32, args ...int) (int, int, int, int)
- func GetHandPid(pid int32, args ...int32) C.MData
- func GetHandle() int
- func GetMousePos() (int, int)
- func GetPID() int32
- func GetTitle(args ...int32) string
- func GetVersion() string
- func GetXId(xu *xgbutil.XUtil, pid int32) (xproto.Window, error)
- func GetXidFromPid(xu *xgbutil.XUtil, pid int32) (xproto.Window, error)
- func GoString(char *C.char) string
- func Is64Bit() bool
- func IsValid() bool
- func KeyTap(tapKey string, args ...interface{}) string
- func KeyToggle(key string, args ...string) string
- func Kill(pid int) error
- func MaxWindow(pid int32, args ...interface{})
- func MicroSleep(tm float64)
- func MilliSleep(tm int)
- func MinWindow(pid int32, args ...interface{})
- func MouseClick(args ...interface{})
- func MouseToggle(togKey string, args ...interface{}) int
- func Move(x, y int)
- func MoveArgs(x, y int) (int, int)
- func MoveClick(x, y int, args ...interface{})
- func MoveMouse(x, y int)
- func MoveMouseSmooth(x, y int, args ...interface{}) bool
- func MoveRelative(x, y int)
- func MoveSmooth(x, y int, args ...interface{}) bool
- func MoveSmoothRelative(x, y int, args ...interface{})
- func MovesClick(x, y int, args ...interface{})
- func PidExists(pid int) (bool, error)
- func Pids() ([]int, error)
- func Scroll(x, y int, args ...int)
- func ScrollMouse(x int, direction string)
- func SetActive(win C.MData)
- func SetDelay(d ...int)
- func SetHandle(hwnd int)
- func SetHandlePid(pid int32, args ...int32)
- func SetKeyDelay(delay int)
- func SetKeyboardDelay(delay int)
- func SetMouseDelay(delay int)
- func ShowAlert(title, msg string, args ...string) bool
- func Sleep(tm int)
- func Start() chan hook.Event
- func StopEvent()
- func Try(fun func(), handler func(interface{}))
- func TypeStr(str string, args ...float64)
- func TypeStrDelay(str string, delay int)
- func TypeString(str string, delay ...int)
- func TypeStringDelayed(str string, delay int)
- func UnicodeType(str uint32)
- type CHex
- type MPoint
- type Map
- type Nps
Constants ¶
const (
// Version get the robotgo version
Version = "v0.91.0.1089, MT. Rainier!"
)
Variables ¶
var Keycode = uMap{
"`": 41,
"1": 2,
"2": 3,
"3": 4,
"4": 5,
"5": 6,
"6": 7,
"7": 8,
"8": 9,
"9": 10,
"0": 11,
"-": 12,
"+": 13,
"q": 16,
"w": 17,
"e": 18,
"r": 19,
"t": 20,
"y": 21,
"u": 22,
"i": 23,
"o": 24,
"p": 25,
"[": 26,
"]": 27,
"\\": 43,
"a": 30,
"s": 31,
"d": 32,
"f": 33,
"g": 34,
"h": 35,
"j": 36,
"k": 37,
"l": 38,
";": 39,
"'": 40,
"z": 44,
"x": 45,
"c": 46,
"v": 47,
"b": 48,
"n": 49,
"m": 50,
",": 51,
".": 52,
"/": 53,
"f1": 59,
"f2": 60,
"f3": 61,
"f4": 62,
"f5": 63,
"f6": 64,
"f7": 65,
"f8": 66,
"f9": 67,
"f10": 68,
"f11": 69,
"f12": 70,
"esc": 1,
"delete": 14,
"tab": 15,
"ctrl": 29,
"control": 29,
"alt": 56,
"space": 57,
"shift": 42,
"rshift": 54,
"enter": 28,
"cmd": 3675,
"command": 3675,
"rcmd": 3676,
"ralt": 3640,
"up": 57416,
"down": 57424,
"left": 57419,
"right": 57421,
}
Keycode robotgo hook key's code map
var MouseMap = uMap{
"left": 1,
"right": 2,
"center": 3,
"wheelDown": 4,
"wheelUp": 5,
"wheelLeft": 6,
"wheelRight": 7,
}
MouseMap robotgo hook mouse's code map
Functions ¶
func ActivePID ¶
ActivePID active the window by PID,
If args[0] > 0 on the Windows platform via a window handle to active, If args[0] > 0 on the unix platform via a xid to active
func ActivePIDC ¶
ActivePIDC active the window by PID, If args[0] > 0 on the unix platform via a xid to active
func AddEvent ¶
AddEvent add event listener,
parameters for the string type, the keyboard corresponding key parameters,
mouse arguments: mleft, center, mright, wheelDown, wheelUp, wheelLeft, wheelRight.
Use "robotgo.AddEvents()" or "gohook" add asynchronous event listener
func AddEvents ¶
AddEvents add global event hook
robotgo.AddEvents("q") robotgo.AddEvents("q", "ctrl") robotgo.AddEvents("q", "ctrl", "shift")
func AddMouse ¶
AddMouse add mouse event hook
mouse arguments: left, center, right, wheelDown, wheelUp, wheelLeft, wheelRight.
robotgo.AddMouse("left") robotgo.AddMouse("left", 100, 100)
func Click ¶
func Click(args ...interface{})
Click click the mouse
robotgo.Click(button string, double bool)
func EventProcess ¶
EventProcess return go hook process
func EventStart ¶
EventStart start global event hook return event channel
func FindIds ¶
FindIds finds the all processes named with a subset of "name" (case insensitive), return matched IDs.
func GetHandPid ¶
GetHandPid get handle mdata by pid
func GetXidFromPid ¶
GetXidFromPid get the xide from pid
func KeyTap ¶
KeyTap tap the keyboard code;
See keys:
https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
func KeyToggle ¶
KeyToggle toggle the keyboard
See keys:
https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
func MouseClick ¶
func MouseClick(args ...interface{})
MouseClick click the mouse
robotgo.MouseClick(button string, double bool)
func MouseToggle ¶
MouseToggle toggle the mouse
func MoveClick ¶
func MoveClick(x, y int, args ...interface{})
MoveClick move and click the mouse
robotgo.MoveClick(x, y int, button string, double bool)
func MoveMouseSmooth ¶
MoveMouseSmooth move the mouse smooth, moves mouse to x, y human like, with the mouse button up.
func MoveSmooth ¶
MoveSmooth move the mouse smooth, moves mouse to x, y human like, with the mouse button up.
robotgo.MoveSmooth(x, y int, low, high float64, mouseDelay int)
func MoveSmoothRelative ¶
func MoveSmoothRelative(x, y int, args ...interface{})
MoveSmoothRelative move mose smooth relative
func MovesClick ¶
func MovesClick(x, y int, args ...interface{})
MovesClick move smooth and click the mouse
func SetHandlePid ¶
SetHandlePid set the window handle by pid
func SetKeyboardDelay ¶
func SetKeyboardDelay(delay int)
SetKeyboardDelay set keyboard delay, Wno-deprecated, this function will be removed in version v1.0.0
func TypeStr ¶
TypeStr send a string, support UTF-8
robotgo.TypeStr(string: The string to send, float64: microsleep time, x11)
func TypeString ¶
TypeString send a string, support unicode TypeStr(string: The string to send), Wno-deprecated
func TypeStringDelayed ¶
TypeStringDelayed type string delayed, Wno-deprecated