robotgo

package module
v0.0.0-...-660d87b Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: Apache-2.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

robot-nocgo

robot-nocgo is a no-cgo focused fork of RobotGo, the Go desktop automation library for controlling the mouse and keyboard, reading the screen, working with window handles, using the clipboard, and querying processes across macOS, Linux, and Windows.

This repository keeps the RobotGo API shape and compatibility goal, while adding and testing pure-Go paths that can be built with CGO_ENABLED=0.

What It Does

  • Provides the familiar robotgo desktop automation API for mouse, keyboard, screen capture, window handle, clipboard, process, bitmap, and alert helpers.
  • Keeps the default cgo RobotGo backend available for normal builds.
  • Adds no-cgo runtime paths for macOS, Linux, and Windows where practical.
  • Adds Linux no-cgo X11 support for screen geometry/capture, mouse movement, scrolling, clicking, and window handles through pure-Go X11/XTEST code.
  • Keeps pure-Go tagged backends for Windows (win), wlroots Wayland (wayland), and GNOME/KDE portal input (libei).
  • Includes no-cgo compatibility tests and smoke programs for cross-platform build/runtime verification.

Relationship To RobotGo

robot-nocgo is based on github.com/go-vgo/robotgo. The upstream RobotGo source, API names, package structure, and Apache-2.0 licensing are preserved. The main difference is that this repository carries additional no-cgo backend work and verification focused on CGO_ENABLED=0 builds.

The module path is:

github.com/leaanthony/robot-nocgo

Import it like any other Go module. The package name is still robotgo, so code can continue using the familiar API names:

import "github.com/leaanthony/robot-nocgo"

func main() {
	robotgo.Move(100, 100)
}

Build Examples

Default RobotGo/cgo build:

go build ./...

No-cgo build on the current platform:

CGO_ENABLED=0 go build ./...

No-cgo cross-compile examples:

CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ./...

Tagged pure-Go backend examples:

CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -tags win ./...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags wayland ./...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags libei ./...

Runtime Notes

  • macOS screen capture and input automation still require the normal Screen Recording and Accessibility permissions.
  • Linux X11 automation requires a running X server and XTEST support.
  • Wayland support depends on compositor protocols; wlroots compositors are the intended target for the wayland backend.
  • The libei backend is for desktop-portal input on GNOME/KDE and intentionally has a smaller support surface than the X11 path.
  • Windows runtime capture/input checks need an interactive desktop session.

Verification Snapshot

The no-cgo work in this fork was verified with local cross-platform compile checks plus runtime smoke tests on macOS, Linux/Xvfb, and Windows interactive desktop sessions. The final verified archive for this work had SHA256:

787b8d31704c7be4630b38d9f127bbf8c704f935174a9e9b6bb71e1d970c2f8a

License

This repository uses the same Apache License 2.0 as RobotGo. See LICENSE.

RobotGo is Copyright (c) 2016-2026 AtomAI and contributors.

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/leaanthony/robot-nocgo#requirements

Installation:

With Go module support (Go 1.11+), just import:

import "github.com/leaanthony/robot-nocgo"

Otherwise, to install the robotgo package, run the command:

go get -u github.com/leaanthony/robot-nocgo

Index

Constants

View Source
const (
	// KeyA define key "a"
	KeyA = "a"
	KeyB = "b"
	KeyC = "c"
	KeyD = "d"
	KeyE = "e"
	KeyF = "f"
	KeyG = "g"
	KeyH = "h"
	KeyI = "i"
	KeyJ = "j"
	KeyK = "k"
	KeyL = "l"
	KeyM = "m"
	KeyN = "n"
	KeyO = "o"
	KeyP = "p"
	KeyQ = "q"
	KeyR = "r"
	KeyS = "s"
	KeyT = "t"
	KeyU = "u"
	KeyV = "v"
	KeyW = "w"
	KeyX = "x"
	KeyY = "y"
	KeyZ = "z"
	//
	CapA = "A"
	CapB = "B"
	CapC = "C"
	CapD = "D"
	CapE = "E"
	CapF = "F"
	CapG = "G"
	CapH = "H"
	CapI = "I"
	CapJ = "J"
	CapK = "K"
	CapL = "L"
	CapM = "M"
	CapN = "N"
	CapO = "O"
	CapP = "P"
	CapQ = "Q"
	CapR = "R"
	CapS = "S"
	CapT = "T"
	CapU = "U"
	CapV = "V"
	CapW = "W"
	CapX = "X"
	CapY = "Y"
	CapZ = "Z"
	//
	Key0      = "0"
	Key1      = "1"
	Key2      = "2"
	Key3      = "3"
	Key4      = "4"
	Key5      = "5"
	Key6      = "6"
	Key7      = "7"
	Key8      = "8"
	Key9      = "9"
	KeyGrave  = "`"
	KeyQuoter = '"'
	KeyQuote  = "'"

	// Backspace backspace key string
	Backspace = "backspace"
	Delete    = "delete"
	Enter     = "enter"
	Tab       = "tab"
	Esc       = "esc"
	Escape    = "escape"
	Up        = "up"    // Up arrow key
	Down      = "down"  // Down arrow key
	Right     = "right" // Right arrow key
	Left      = "left"  // Left arrow key
	Home      = "home"
	End       = "end"
	Pageup    = "pageup"
	Pagedown  = "pagedown"

	F1  = "f1"
	F2  = "f2"
	F3  = "f3"
	F4  = "f4"
	F5  = "f5"
	F6  = "f6"
	F7  = "f7"
	F8  = "f8"
	F9  = "f9"
	F10 = "f10"
	F11 = "f11"
	F12 = "f12"
	F13 = "f13"
	F14 = "f14"
	F15 = "f15"
	F16 = "f16"
	F17 = "f17"
	F18 = "f18"
	F19 = "f19"
	F20 = "f20"
	F21 = "f21"
	F22 = "f22"
	F23 = "f23"
	F24 = "f24"

	Cmd  = "cmd"  // is the "win" key for windows
	CmdL = "cmdl" // left command
	CmdR = "cmdr" // right command
	// "command"
	Alt     = "alt"
	AltL    = "altl" // left alt
	AltR    = "altr" // right alt
	Ctrl    = "ctrl"
	CtrlL   = "ctrll" // left ctrl
	CtrlR   = "ctrlr" // right ctrl
	Control = "control"
	Shift   = "shift"
	ShiftL  = "shiftl" // left shift
	ShiftR  = "shiftr" // right shift
	// "right_shift"
	Capslock    = "capslock"
	Space       = "space"
	Print       = "print"
	Printscreen = "printscreen" // No Mac support
	Insert      = "insert"
	Menu        = "menu" // Windows only
	ScrollLock  = "scroll_lock"
	PauseBreak  = "pause_break"

	AudioMute    = "audio_mute"     // Mute the volume
	AudioVolDown = "audio_vol_down" // Lower the volume
	AudioVolUp   = "audio_vol_up"   // Increase the volume
	AudioPlay    = "audio_play"
	AudioStop    = "audio_stop"
	AudioPause   = "audio_pause"
	AudioPrev    = "audio_prev"    // Previous Track
	AudioNext    = "audio_next"    // Next Track
	AudioRewind  = "audio_rewind"  // Linux only
	AudioForward = "audio_forward" // Linux only
	AudioRepeat  = "audio_repeat"  //  Linux only
	AudioRandom  = "audio_random"  //  Linux only

	Num0    = "num0" // numpad 0
	Num1    = "num1"
	Num2    = "num2"
	Num3    = "num3"
	Num4    = "num4"
	Num5    = "num5"
	Num6    = "num6"
	Num7    = "num7"
	Num8    = "num8"
	Num9    = "num9"
	NumLock = "num_lock"

	NumDecimal = "num."
	NumPlus    = "num+"
	NumMinus   = "num-"
	NumMul     = "num*"
	NumDiv     = "num/"
	NumClear   = "num_clear"
	NumEnter   = "num_enter"
	NumEqual   = "num_equal"

	LightsMonUp     = "lights_mon_up"     // Turn up monitor brightness			No Windows support
	LightsMonDown   = "lights_mon_down"   // Turn down monitor brightness		No Windows support
	LightsKbdToggle = "lights_kbd_toggle" // Toggle keyboard backlight on/off		No Windows support
	LightsKbdUp     = "lights_kbd_up"     // Turn up keyboard backlight brightness	No Windows support
	LightsKbdDown   = "lights_kbd_down"
)

Defining a bunch of constants.

View Source
const (
	// Mleft mouse left button
	Mleft      = "left"
	Mright     = "right"
	Center     = "center"
	WheelDown  = "wheelDown"
	WheelUp    = "wheelUp"
	WheelLeft  = "wheelLeft"
	WheelRight = "wheelRight"
)
View Source
const (
	// Version get the robotgo version
	Version = "v2.00.0.1658, MT. Baker!"
)

Variables

View Source
var (
	// MouseSleep set the mouse default millisecond sleep time
	MouseSleep = 0
	// KeySleep set the key default millisecond sleep time
	KeySleep = 10

	// DisplayID set the screen display id
	DisplayID = -1

	// NotPid used the hwnd not pid in windows
	NotPid bool
	// Scale option the os screen scale
	Scale bool
)
View Source
var Keycode = keycode.Keycode

Keycode robotgo hook key's code map

View Source
var MouseMap = keycode.MouseMap

MouseMap robotgo hook mouse's code map

View Source
var Special = keycode.Special

Special is the special key map

Functions

func ActiveName

func ActiveName(name string) error

ActiveName active the window by name

Examples:

robotgo.ActiveName("chrome")

func ActivePid

func ActivePid(pid int, args ...int) error

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

func ActivePidC(pid int, args ...int) error

ActivePidC active the window by Pid, If args[0] > 0 on the unix platform via a xid to active

func Alert

func Alert(title, msg string, args ...string) bool

Alert show a alert window Displays alert with the attributes. If cancel button is not given, only the default button is displayed

Examples:

robotgo.Alert("hi", "window", "ok", "cancel")

func ByteToImg

func ByteToImg(b []byte) (image.Image, error)

ByteToImg convert []byte to image.Image

func Capture

func Capture(args ...int) (*image.RGBA, error)

Capture capture the screenshot, use the CaptureImg default

func Capture1

func Capture1(args ...int) (*image.RGBA, error)

Capture1 captures the screen and returns an RGBA image.

func CaptureImg

func CaptureImg(args ...int) (image.Image, error)

CaptureImg capture the screen and return image.Image, error

func CharCodeAt

func CharCodeAt(s string, n int) rune

CharCodeAt char code at utf-8

func CheckMouse

func CheckMouse(btn string) C.MMMouseButton

CheckMouse check the mouse button

func Click

func Click(args ...interface{}) error

Click click the mouse button and return error

robotgo.Click(button string, double bool)

Examples:

err := robotgo.Click() // default is left button
err := robotgo.Click("right")

func ClickV1

func ClickV1(args ...interface{})

ClickV1 click the mouse button

robotgo.Click(button string, double bool)

Examples:

robotgo.Click() // default is left button
robotgo.Click("right")
robotgo.Click("wheelLeft")

func CloseMainDisplay

func CloseMainDisplay()

CloseMainDisplay close the main X11 display

func CloseWindow

func CloseWindow(args ...int)

CloseWindow close the window

func CmdCtrl

func CmdCtrl() string

CmdCtrl If the operating system is macOS, return the key string "cmd", otherwise return the key string "ctrl"

func CmdV

func CmdV() error

CmdV tap key command + v or control + v

func DecodeImg

func DecodeImg(path string) (image.Image, string, error)

DecodeImg decode the image to image.Image and return

func DisplaysNum

func DisplaysNum() int

DisplaysNum get the count of displays

func Drag deprecated

func Drag(x, y int, args ...string)

Deprecated: use the DragSmooth(),

Drag drag the mouse to (x, y), It's not valid now, use the DragSmooth()

func DragMouse deprecated

func DragMouse(x, y int, args ...interface{})

Deprecated: use the DragSmooth(),

DragMouse drag the mouse to (x, y), It's same with the DragSmooth() now

func DragSmooth

func DragSmooth(x, y int, args ...interface{})

DragSmooth drag the mouse like smooth to (x, y)

Examples:

robotgo.DragSmooth(10, 10)

func FindIds

func FindIds(name string) ([]int, error)

FindIds finds the all processes named with a subset of "name" (case insensitive), return matched IDs.

func FindName

func FindName(pid int) (string, error)

FindName find the process name by the process id

func FindNames

func FindNames() ([]string, error)

FindNames find the all process name

func FindPath

func FindPath(pid int) (string, error)

FindPath find the process path by the process pid

func FreeBitmap

func FreeBitmap(bitmap CBitmap)

FreeBitmap free and dealloc the C bitmap

func FreeBitmapArr

func FreeBitmapArr(bit ...CBitmap)

FreeBitmapArr free and dealloc the C bitmap array

func GetActiveC

func GetActiveC() C.MData

GetActiveC get the active window

func GetBHandle deprecated

func GetBHandle() int

Deprecated: use the GetHandle(),

GetBHandle get the window handle, Wno-deprecated

This function will be removed in version v1.0.0

func GetBounds

func GetBounds(pid int, args ...int) (int, int, int, int)

GetBounds get the window bounds

func GetClient

func GetClient(pid int, args ...int) (int, int, int, int)

GetClient get the window client bounds

func GetDisplayBounds

func GetDisplayBounds(i int) (x, y, w, h int)

GetDisplayBounds gets the display screen bounds

func GetHWNDByPid

func GetHWNDByPid(pid int) int

GetHWNDByPid get the hwnd by pid

func GetHandByPidC

func GetHandByPidC(pid int, args ...int) C.MData

GetHandByPidC get handle mdata by pid

func GetHandle

func GetHandle() int

GetHandle get the window handle

func GetLocationColor

func GetLocationColor(displayId ...int) string

GetLocationColor get the location pos's color

func GetMainId

func GetMainId() int

GetMainId get the main display id

func GetMousePos deprecated

func GetMousePos() (int, int)

Deprecated: use the function Location()

GetMousePos get the mouse's position return x, y

func GetPid

func GetPid() int

GetPid get the process id return int32

func GetPixelColor

func GetPixelColor(x, y int, displayId ...int) string

GetPixelColor get the pixel color return string

func GetPxColor

func GetPxColor(x, y int, displayId ...int) C.MMRGBHex

GetPxColor get the pixel color return C.MMRGBHex

func GetScaleSize

func GetScaleSize(displayId ...int) (int, int)

GetScaleSize get the screen scale size

func GetScreenSize

func GetScreenSize() (int, int)

GetScreenSize get the screen size

func GetText

func GetText(imgPath string, args ...string) (string, error)

GetText get the image text by tesseract ocr

robotgo.GetText(imgPath, lang string)

func GetTitle

func GetTitle(args ...int) string

GetTitle get the window title return string

Examples:

fmt.Println(robotgo.GetTitle())

ids, _ := robotgo.FindIds()
robotgo.GetTitle(ids[0])

func GetVersion

func GetVersion() string

GetVersion get the robotgo version

func GetXDisplayName

func GetXDisplayName() string

GetXDisplayName get XDisplay name (Linux)

func GetXid

func GetXid(xu *xgbutil.XUtil, pid int) (xproto.Window, error)

GetXid get the xid return window and error

func GetXidByPid

func GetXidByPid(xu *xgbutil.XUtil, pid int) (xproto.Window, error)

GetXidByPid get the xid from pid

func GetXidFromPid deprecated

func GetXidFromPid(xu *xgbutil.XUtil, pid int) (xproto.Window, error)

Deprecated: use the GetXidByPid(),

GetXidFromPid get the xid from pid

func GoString

func GoString(char *C.char) string

GoString trans C.char to string

func Height

func Height(img image.Image) int

Height return the image.Image height

func HexToRgb

func HexToRgb(hex uint32) *C.uint8_t

HexToRgb trans hex to rgb

func ImgSize

func ImgSize(path string) (int, int, error)

ImgSize get the file image size

func Is64Bit

func Is64Bit() bool

Is64Bit determine whether the sys is 64bit

func IsMain

func IsMain(displayId int) bool

IsMain is main display

func IsValid

func IsValid() bool

IsValid valid the window

func KeyDown

func KeyDown(key string, args ...interface{}) error

KeyDown press down a key

func KeyPress

func KeyPress(key string, args ...interface{}) error

KeyPress press key string

func KeyTap

func KeyTap(key string, args ...interface{}) error

KeyTap taps the keyboard code;

See keys supported:

https://github.com/leaanthony/robot-nocgo/blob/master/docs/keys.md#keys

Examples:

robotgo.KeySleep = 100 // 100 millisecond
robotgo.KeyTap("a")
robotgo.KeyTap("i", "alt", "command")

arr := []string{"alt", "command"}
robotgo.KeyTap("i", arr)

robotgo.KeyTap("k", pid int)

func KeyToggle

func KeyToggle(key string, args ...interface{}) error

KeyToggle toggles the keyboard, if there not have args default is "down"

See keys:

https://github.com/leaanthony/robot-nocgo/blob/master/docs/keys.md#keys

Examples:

robotgo.KeyToggle("a")
robotgo.KeyToggle("a", "up")

robotgo.KeyToggle("a", "up", "alt", "cmd")
robotgo.KeyToggle("k", pid int)

func KeyUp

func KeyUp(key string, args ...interface{}) error

KeyUp press up a key

func Kill

func Kill(pid int) error

Kill kill the process by PID

func Location

func Location() (int, int)

Location get the mouse location position return x, y

func MaxWindow

func MaxWindow(pid int, args ...interface{})

MaxWindow set the window max

func MicroSleep deprecated

func MicroSleep(tm float64)

Deprecated: use the MilliSleep(),

MicroSleep time C.microsleep(tm)

func MilliSleep

func MilliSleep(tm int)

MilliSleep sleep tm milli second

func MinWindow

func MinWindow(pid int, args ...interface{})

MinWindow set the window min

func MouseButtonString

func MouseButtonString(btn C.MMMouseButton) string

MouseButtonString converts a C.MMMouseButton to a readable name.

func MouseClick deprecated

func MouseClick(args ...interface{})

Deprecated: use the Click(),

MouseClick click the mouse

robotgo.MouseClick(button string, double bool)

func MouseDown

func MouseDown(key ...interface{}) error

MouseDown send mouse down event

func MouseUp

func MouseUp(key ...interface{}) error

MouseUp send mouse up event

func Move

func Move(x, y int, displayId ...int)

Move move the mouse to (x, y)

Examples:

robotgo.MouseSleep = 100  // 100 millisecond
robotgo.Move(10, 10)

func MoveArgs

func MoveArgs(x, y int) (int, int)

MoveArgs get the mouse relative args

func MoveClick

func MoveClick(x, y int, args ...interface{})

MoveClick move and click the mouse

robotgo.MoveClick(x, y int, button string, double bool)

Examples:

robotgo.MouseSleep = 100
robotgo.MoveClick(10, 10)

func MoveMouse deprecated

func MoveMouse(x, y int)

Deprecated: use the Move(),

MoveMouse move the mouse

func MoveMouseSmooth deprecated

func MoveMouseSmooth(x, y int, args ...interface{}) bool

Deprecated: use the MoveSmooth(),

MoveMouseSmooth move the mouse smooth, moves mouse to x, y human like, with the mouse button up.

func MoveRelative

func MoveRelative(x, y int)

MoveRelative move mouse with relative

func MoveScale

func MoveScale(x, y int, displayId ...int) (int, int)

MoveScale calculate the os scale factor x, y

func MoveSmooth

func MoveSmooth(x, y int, args ...interface{}) bool

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)

Examples:

robotgo.MoveSmooth(10, 10)
robotgo.MoveSmooth(10, 10, 1.0, 2.0)

func MoveSmoothRelative

func MoveSmoothRelative(x, y int, args ...interface{})

MoveSmoothRelative move mouse smooth with relative

func MovesClick

func MovesClick(x, y int, args ...interface{})

MovesClick move smooth and click the mouse

use the `robotgo.MouseSleep = 100`

func Mul deprecated

func Mul(x int) int

Deprecated: use the ScaledF(),

Mul mul the scale, drop

func MultiClick

func MultiClick(button string, count int, click ...bool) error

MultiClick performs multiple clicks and returns error

robotgo.MultiClick(button string, count int)

func OpenImg

func OpenImg(path string) ([]byte, error)

OpenImg open the image return []byte

func PadHex

func PadHex(hex C.MMRGBHex) string

PadHex trans C.MMRGBHex to string

func PadHexs

func PadHexs(hex CHex) string

PadHexs trans CHex to string

func Paste

func Paste(str string) error

Paste paste a string (supported UTF-8), write the string to clipboard and tap `cmd + v`

func PasteStr deprecated

func PasteStr(str string) error

PasteStr paste a string

Deprecated: use the Paste()

func PidExists

func PidExists(pid int) (bool, error)

PidExists determine whether the process exists

func Pids

func Pids() ([]int, error)

Pids get the all process id

func Read

func Read(path string) (image.Image, error)

Read read the file return image.Image

func ReadAll

func ReadAll() (string, error)

ReadAll read string from clipboard

func RgbToHex

func RgbToHex(r, g, b uint8) C.uint32_t

RgbToHex trans rgb to hex

func Run

func Run(path string) ([]byte, error)

Run run a cmd shell

func Save

func Save(img image.Image, path string, quality ...int) error

Save create a image file with the image.Image

func SaveCapture

func SaveCapture(path string, args ...int) error

SaveCapture capture screen and save the screenshot to image

func SaveCaptureGo

func SaveCaptureGo(path string, args ...int) error

SaveCaptureGo capture screen and save the screenshot to image

func SaveImg

func SaveImg(b []byte, path string) error

SaveImg save the image by []byte

func SaveJpeg

func SaveJpeg(img image.Image, path string, quality ...int) error

SaveJpeg save the image by image.Image

func SavePng

func SavePng(img image.Image, path string) error

SavePng save the image by image.Image

func Scale0 deprecated

func Scale0() int

Deprecated: use the ScaledF(),

Scale0 return ScaleX() / 0.96, drop

func Scale1 deprecated

func Scale1() int

Deprecated: use the ScaledF(),

Scale1 get the screen scale (only windows old), drop

func ScaleF

func ScaleF(displayId ...int) float64

ScaleF get the system scale val

func ScaleX deprecated

func ScaleX() int

Deprecated: use the ScaledF(),

ScaleX get the primary display horizontal DPI scale factor, drop

func Scaled

func Scaled(x int, displayId ...int) int

Scaled get the screen scaled return scale size

func Scaled0

func Scaled0(x int, f float64) int

Scaled0 return int(x * f)

func Scaled1

func Scaled1(x int, f float64) int

Scaled1 return int(x / f)

func Scroll

func Scroll(x, y int, args ...int)

Scroll scroll the mouse to (x, y)

robotgo.Scroll(x, y, msDelay int)

Examples:

robotgo.Scroll(10, 10)

func ScrollDir

func ScrollDir(x int, direction ...interface{})

ScrollDir scroll the mouse with direction to (x, "up") supported: "up", "down", "left", "right"

Examples:

robotgo.ScrollDir(10, "down")
robotgo.ScrollDir(10, "up")

func ScrollRelative

func ScrollRelative(x, y int, args ...int)

ScrollRelative scroll mouse with relative

Examples:

robotgo.ScrollRelative(10, 10)

func ScrollSmooth

func ScrollSmooth(to int, args ...int)

ScrollSmooth scroll the mouse smooth, default scroll 5 times and sleep 100 millisecond

robotgo.ScrollSmooth(toy, num, sleep, tox)

Examples:

robotgo.ScrollSmooth(-10)
robotgo.ScrollSmooth(-10, 6, 200, -10)

func SetActive

func SetActive(win Handle)

SetActive set the window active

func SetActiveC

func SetActiveC(win C.MData)

SetActiveC set the window active

func SetDelay

func SetDelay(d ...int)

SetDelay sets the key and mouse delay robotgo.SetDelay(100) option the robotgo.KeySleep and robotgo.MouseSleep = d

func SetHandle

func SetHandle(hwnd int)

SetHandle set the window handle

func SetHandlePid

func SetHandlePid(pid int, args ...int)

SetHandlePid set the window handle by pid

func SetXDisplayName

func SetXDisplayName(name string) error

SetXDisplayName set XDisplay name (Linux)

func Sleep

func Sleep(tm int)

Sleep time.Sleep tm second

func StrToImg

func StrToImg(data string) (image.Image, error)

StrToImg convert base64 string to image.Image

func SysScale

func SysScale(displayId ...int) float64

SysScale get the sys scale

func ToByteImg

func ToByteImg(img image.Image, fm ...string) []byte

ToByteImg convert image.Image to []byte

func ToImage

func ToImage(bit CBitmap) image.Image

ToImage convert C.MMBitmapRef to standard image.Image

func ToInterfaces

func ToInterfaces(fields []string) []interface{}

ToInterfaces convert []string to []interface{}

func ToMMBitmapRef

func ToMMBitmapRef(bit CBitmap) C.MMBitmapRef

ToMMBitmapRef trans CBitmap to C.MMBitmapRef

func ToMMRGBHex

func ToMMRGBHex(hex CHex) C.MMRGBHex

ToMMRGBHex trans CHex to C.MMRGBHex

func ToRGBA

func ToRGBA(bit CBitmap) *image.RGBA

ToRGBA convert C.MMBitmapRef to standard image.RGBA

func ToRGBAGo

func ToRGBAGo(bmp1 Bitmap) *image.RGBA

ToRGBAGo convert Bitmap to standard image.RGBA

func ToStringImg

func ToStringImg(img image.Image, fm ...string) string

ToStringImg convert image.Image to string

func ToStrings

func ToStrings(fields []interface{}) []string

ToStrings convert []interface{} to []string

func ToUC

func ToUC(text string) []string

ToUC trans string to unicode []string

func ToUint8p

func ToUint8p(dst []uint8) *uint8

ToUint8p convert the []uint8 to uint8 pointer

func Toggle

func Toggle(key ...interface{}) error

Toggle toggle the mouse, support button:

	"left", "center", "right",
 "wheelDown", "wheelUp", "wheelLeft", "wheelRight"

Examples:

robotgo.Toggle("left") // default is down
robotgo.Toggle("left", "up")

func Try

func Try(fun func(), handler func(interface{}))

Try handler(err)

func Type

func Type(str string, args ...int)

Type type a string (supported UTF-8)

robotgo.Type(string: "The string to send", int: pid, "milli_sleep time", "x11 option")

Examples:

robotgo.Type("abc@123, Hi galaxy, こんにちは")
robotgo.Type("To be or not to be, this is questions.", pid int)

func TypeDelay

func TypeDelay(str string, delay int)

TypeDelay type string with delayed And you can use robotgo.KeySleep = 100 to delayed not this function

func TypeStr deprecated

func TypeStr(str string, args ...int)

TypeStr tap a string

Deprecated: use the Type()

func TypeStrDelay deprecated

func TypeStrDelay(str string, delay int)

TypeStrDelay type string width delay

Deprecated: use the TypeDelay()

func TypeStringDelayed deprecated

func TypeStringDelayed(str string, delay int)

Deprecated: use the TypeStr(),

TypeStringDelayed type string delayed, Wno-deprecated

This function will be removed in version v1.0.0

func U8ToHex

func U8ToHex(hex *C.uint8_t) C.MMRGBHex

U8ToHex trans *C.uint8_t to C.MMRGBHex

func U32ToHex

func U32ToHex(hex C.uint32_t) C.MMRGBHex

U32ToHex trans C.uint32_t to C.MMRGBHex

func UnicodeType

func UnicodeType(str uint32, args ...int)

UnicodeType tap the uint32 unicode

func Width

func Width(img image.Image) int

Width return the image.Image width

func WriteAll

func WriteAll(text string) error

WriteAll write string to clipboard

Types

type Bitmap

type Bitmap struct {
	ImgBuf        *uint8
	Width, Height int

	Bytewidth     int
	BitsPixel     uint8
	BytesPerPixel uint8
}

Bitmap define the go Bitmap struct

The common type conversion of bitmap:

https://github.com/leaanthony/robot-nocgo/blob/master/docs/keys.md#type-conversion

func CaptureGo

func CaptureGo(args ...int) Bitmap

CaptureGo capture the screen and return bitmap(go struct)

func ImgToBitmap

func ImgToBitmap(m image.Image) (bit Bitmap)

ImgToBitmap convert the standard image.Image to Bitmap

func RGBAToBitmap

func RGBAToBitmap(r1 *image.RGBA) (bit Bitmap)

RGBAToBitmap convert the standard image.RGBA to Bitmap

func ToBitmap

func ToBitmap(bit CBitmap) Bitmap

ToBitmap trans C.MMBitmapRef to Bitmap

type CBitmap

type CBitmap C.MMBitmapRef

CBitmap define CBitmap as C.MMBitmapRef type

func ByteToCBitmap

func ByteToCBitmap(by []byte) CBitmap

ByteToCBitmap trans []byte to CBitmap

func CaptureScreen

func CaptureScreen(args ...int) CBitmap

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 ImgToCBitmap

func ImgToCBitmap(img image.Image) CBitmap

ImgToCBitmap trans image.Image to CBitmap

func ToCBitmap

func ToCBitmap(bit Bitmap) CBitmap

ToCBitmap trans Bitmap to C.MMBitmapRef

type CHex

type CHex C.MMRGBHex

CHex define CHex as c rgb Hex type (C.MMRGBHex)

func UintToHex

func UintToHex(u uint32) CHex

UintToHex trans uint32 to robotgo.CHex

type Handle

type Handle C.MData

Handle define window Handle as C.MData type

func GetActive

func GetActive() Handle

GetActive get the active window

func GetHandById

func GetHandById(id int, args ...int) Handle

GetHandById get handle mdata by id

func GetHandByPid

func GetHandByPid(pid int, args ...int) Handle

GetHandByPid get handle mdata by pid

func GetHandPid deprecated

func GetHandPid(pid int, args ...int) Handle

Deprecated: use the GetHandByPid(),

GetHandPid get handle mdata by pid

type Map

type Map map[string]interface{}

Map a map[string]interface{}

type Nps

type Nps struct {
	Pid  int
	Name string
}

Nps process struct

func Process

func Process() ([]Nps, error)

Process get the all process struct

type Point

type Point struct {
	X int
	Y int
}

Point is point struct

type Rect

type Rect struct {
	Point
	Size
}

Rect is rect structure

func GetDisplayRect

func GetDisplayRect(i int) Rect

GetDisplayRect gets the display rect

func GetScreenRect

func GetScreenRect(displayId ...int) Rect

GetScreenRect get the screen rect (x, y, w, h)

type Size

type Size struct {
	W, H int
}

Size is size structure

Directories

Path Synopsis
https://github.com/golang/go/issues/26366
https://github.com/golang/go/issues/26366
Package clipboard read/write on clipboard
Package clipboard read/write on clipboard
cmd/gocopy command
cmd/gopaste command
example command
key command
mouse command
scale command
screen command
window command
Package libei provides a pure-Go libei/portal implementation of the robotgo API for desktop automation on Wayland compositors that do NOT expose the wlroots virtual-input protocols — most importantly GNOME (Mutter) and KDE Plasma (KWin).
Package libei provides a pure-Go libei/portal implementation of the robotgo API for desktop automation on Wayland compositors that do NOT expose the wlroots virtual-input protocols — most importantly GNOME (Mutter) and KDE Plasma (KWin).
test
nocgo_smoke command
Package wayland provides a pure-Go Wayland implementation of the robotgo API for desktop automation on wlroots-based compositors (Sway, Hyprland, Wayfire, etc.).
Package wayland provides a pure-Go Wayland implementation of the robotgo API for desktop automation on wlroots-based compositors (Sway, Hyprland, Wayfire, etc.).
Package win provides a pure-Go Windows implementation of the robotgo API for desktop automation: mouse, keyboard, screen capture, window management and process enumeration.
Package win provides a pure-Go Windows implementation of the robotgo API for desktop automation: mouse, keyboard, screen capture, window management and process enumeration.

Jump to

Keyboard shortcuts

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