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 BitmapClick(bitmap C.MMBitmapRef, args ...interface{})
- func BitmapFromStr(str string) C.MMBitmapRef
- func BitmapStr(str string) C.MMBitmapRef
- func ByteToImg(b []byte) (image.Image, error)
- func CaptureScreen(args ...int) C.MMBitmapRef
- func CharCodeAt(s string, n int) rune
- func CheckMouse(btn string) C.MMMouseButton
- func Click(args ...interface{})
- func CloseWindow(args ...int32)
- func Convert(opath, spath string, args ...int)
- func CopyBitPB(bitmap C.MMBitmapRef) bool
- func CopyBitpb(bitmap C.MMBitmapRef) bool
- func CountBitmap(bitmap, sbit C.MMBitmapRef, args ...float32) int
- func CountColor(color CHex, args ...interface{}) int
- func CountColorCS(color CHex, x, y, w, h int, args ...float64) int
- func DecodeImg(path string) (image.Image, string, error)
- func DeepCopyBit(bitmap C.MMBitmapRef) C.MMBitmapRef
- 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 FindBitmap(bit C.MMBitmapRef, args ...interface{}) (int, int)
- func FindCBitmap(bmp CBitmap, args ...interface{}) (int, int)
- func FindColor(color CHex, args ...interface{}) (int, int)
- func FindColorCS(color CHex, x, y, w, h int, args ...float64) (int, int)
- func FindIds(name string) ([]int32, error)
- func FindName(pid int32) (string, error)
- func FindNames() ([]string, error)
- func FindPath(pid int32) (string, error)
- func FindPic(path string, args ...interface{}) (int, int)
- func FreeBitmap(bitmap C.MMBitmapRef)
- func FreeMMPointArr(pointArray C.MMPointArrayRef)
- func GetActive() C.MData
- func GetBHandle() int
- func GetBounds(pid int32, args ...int) (int, int, int, int)
- func GetColor(bitmap C.MMBitmapRef, x, y int) C.MMRGBHex
- func GetColors(bitmap C.MMBitmapRef, x, y int) string
- func GetHandPid(pid int32, args ...int32) C.MData
- func GetHandle() int
- func GetImgSize(imgPath string) (int, int)
- func GetMouseColor() string
- func GetMousePos() (int, int)
- func GetPID() int32
- func GetPixelColor(x, y int) string
- func GetPortion(bit C.MMBitmapRef, x, y, w, h int) C.MMBitmapRef
- func GetPxColor(x, y int) C.MMRGBHex
- func GetScaleSize() (int, int)
- func GetScreenSize() (int, int)
- func GetText(imgPath string, args ...string) (string, error)
- func GetTitle(args ...int32) string
- func GetVersion() string
- func GetXDisplayName() 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 HexToRgb(hex uint32) *C.uint8_t
- func Is64Bit() bool
- func IsValid() bool
- func KeyTap(tapKey string, args ...interface{}) string
- func KeyToggle(key string, args ...string) string
- func Kill(pid int32) 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 Mul(x int) int
- func OpenBitmap(gpath string, args ...int) C.MMBitmapRef
- func OpenImg(path string) ([]byte, error)
- func PadHex(hex C.MMRGBHex) string
- func PasteStr(str string) string
- func PidExists(pid int32) (bool, error)
- func Pids() ([]int32, error)
- func PointInBounds(bitmap C.MMBitmapRef, x, y int) bool
- func ReadAll() (string, error)
- func ReadBitmap(bitmap C.MMBitmapRef) bool
- func RgbToHex(r, g, b uint8) C.uint32_t
- func SaveBitmap(bitmap C.MMBitmapRef, gpath string, args ...int) string
- func SaveCapture(spath string, args ...int)
- func SaveImg(b []byte, path string) error
- func SavePng(img image.Image, path string) error
- func Scale() int
- func ScaleX() int
- func ScaleY() int
- func Scaled(x int) int
- 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 SetXDisplayName(name string) string
- func ShowAlert(title, msg string, args ...string) bool
- func Sleep(tm int)
- func Start() chan hook.Event
- func StopEvent()
- func SysScale() float64
- func ToBitmapBytes(bit C.MMBitmapRef) []byte
- func ToCBitmap(bit Bitmap) C.MMBitmapRef
- func ToImage(bit C.MMBitmapRef) image.Image
- func ToMMBitmapRef(bit CBitmap) C.MMBitmapRef
- func ToMMRGBHex(hex CHex) C.MMRGBHex
- func TocharBitmap(bit C.MMBitmapRef) *C.char
- func TostringBitmap(bit C.MMBitmapRef) string
- 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 U32ToHex(hex C.uint32_t) C.MMRGBHex
- func U8ToHex(hex *C.uint8_t) C.MMRGBHex
- func UnicodeType(str uint32)
- func WriteAll(text string) error
- type Bitmap
- type CBitmap
- type CHex
- type MPoint
- type Map
- type Nps
Constants ¶
const (
// Version get the robotgo version
Version = "v0.93.1.1189, 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 BitmapClick ¶
func BitmapClick(bitmap C.MMBitmapRef, args ...interface{})
BitmapClick find the bitmap and click
func CaptureScreen ¶
func CaptureScreen(args ...int) C.MMBitmapRef
CaptureScreen capture the screen return bitmap(c struct), use `defer robotgo.FreeBitmap(bitmap)` to free the bitmap
robotgo.CaptureScreen(x, y, w, h int)
func Click ¶
func Click(args ...interface{})
Click click the mouse
robotgo.Click(button string, double bool)
func CopyBitpb ¶
func CopyBitpb(bitmap C.MMBitmapRef) bool
CopyBitpb copy bitmap to pasteboard, Wno-deprecated
func CountBitmap ¶
func CountBitmap(bitmap, sbit C.MMBitmapRef, args ...float32) int
CountBitmap count of the bitmap
func CountColor ¶
CountColor count bitmap color
func CountColorCS ¶
CountColorCS count bitmap color by CaptureScreen
func DeepCopyBit ¶
func DeepCopyBit(bitmap C.MMBitmapRef) C.MMBitmapRef
DeepCopyBit deep copy bitmap
func EventProcess ¶
EventProcess return go hook process
func EventStart ¶
EventStart start global event hook return event channel
func FindBitmap ¶
func FindBitmap(bit C.MMBitmapRef, args ...interface{}) (int, int)
FindBitmap find the bitmap's pos
robotgo.FindBitmap(bitmap, subbitamp C.MMBitmapRef, tolerance float64) |tolerance| should be in the range 0.0f - 1.0f, denoting how closely the colors in the bitmaps need to match, with 0 being exact and 1 being any.
This method only automatically free the internal bitmap, use `defer robotgo.FreeBitmap(bit)` to free the bitmap
func FindCBitmap ¶
FindCBitmap find bitmap's pos by CBitmap
func FindColor ¶
FindColor find bitmap color
robotgo.FindColor(color CHex, bitmap C.MMBitmapRef, tolerance float)
func FindColorCS ¶
FindColorCS findcolor by CaptureScreen
func FindIds ¶
FindIds finds the all processes named with a subset of "name" (case insensitive), return matched IDs.
func FindPic ¶
FindPic finding the image by path
robotgo.FindPic(path string, subbitamp C.MMBitmapRef, tolerance float64)
This method only automatically free the internal bitmap, use `defer robotgo.FreeBitmap(bit)` to free the bitmap
func FreeMMPointArr ¶ added in v0.93.0
func FreeMMPointArr(pointArray C.MMPointArrayRef)
FreeMMPointArr free MMPoint array
func GetColors ¶
func GetColors(bitmap C.MMBitmapRef, x, y int) string
GetColors get bitmap color retrun string
func GetHandPid ¶
GetHandPid get handle mdata by pid
func GetPixelColor ¶
GetPixelColor get pixel color return string
func GetPortion ¶
func GetPortion(bit C.MMBitmapRef, x, y, w, h int) C.MMBitmapRef
GetPortion get bitmap portion
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 OpenBitmap ¶
func OpenBitmap(gpath string, args ...int) C.MMBitmapRef
OpenBitmap open the bitmap return C.MMBitmapRef
robotgo.OpenBitmap(path string, type int)
func PointInBounds ¶
func PointInBounds(bitmap C.MMBitmapRef, x, y int) bool
PointInBounds bitmap point in bounds
func ReadBitmap ¶
func ReadBitmap(bitmap C.MMBitmapRef) bool
ReadBitmap returns false and sets error if |bitmap| is NULL
func SaveBitmap ¶
func SaveBitmap(bitmap C.MMBitmapRef, gpath string, args ...int) string
SaveBitmap save the bitmap to image
robotgo.SaveBimap(bitmap C.MMBitmapRef, path string, type int)
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 SetXDisplayName ¶
SetXDisplayName set XDisplay name (Linux)
func ToBitmapBytes ¶
func ToBitmapBytes(bit C.MMBitmapRef) []byte
ToBitmapBytes saves Bitmap to bitmap format in bytes
func ToImage ¶ added in v0.92.0
func ToImage(bit C.MMBitmapRef) image.Image
ToImage convert C.MMBitmapRef to standard image.Image
func ToMMBitmapRef ¶
func ToMMBitmapRef(bit CBitmap) C.MMBitmapRef
ToMMBitmapRef trans CBitmap to C.MMBitmapRef
func TocharBitmap ¶
func TocharBitmap(bit C.MMBitmapRef) *C.char
TocharBitmap tostring bitmap to C.char
func TostringBitmap ¶
func TostringBitmap(bit C.MMBitmapRef) string
TostringBitmap tostring bitmap to string
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
Types ¶
type Bitmap ¶
type Bitmap struct { ImgBuf *uint8 Width, Height int Bytewidth int BitsPixel uint8 BytesPerPixel uint8 }
Bitmap is Bitmap struct
func GoCaptureScreen ¶
GoCaptureScreen capture the screen and return bitmap(go struct)
type MPoint ¶
MPoint is MPoint struct
func FindEveryBitmap ¶
func FindEveryBitmap(bit C.MMBitmapRef, args ...interface{}) (posArr []MPoint)
FindEveryBitmap find the every bitmap
func FindEveryColor ¶ added in v0.93.0
FindEveryColor find every color
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package clipboard read/write on clipboard
|
Package clipboard read/write on clipboard |